Skip to content

Commit

Permalink
Improve searching for a branch-name in git reflog.
Browse files Browse the repository at this point in the history
I was doing a grep for `branch-name`, but this was matching all
branches which had `branch-name` as a substring.  (Actually as a
prefix, given how the regexp turned out.)  Now I look for a more exact
match.

Auditors: benkraft

Test plan:
Ran `git reparent` when I the parent branch was user-data but I also
had done work recently on user-data-is_advocate, and it succeeded
after this change but failed before.
  • Loading branch information
csilvers committed Jul 17, 2018
1 parent 9ce13f4 commit 8d3b906
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bin/git-reparent
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ head_of_old_upstream() {
# take the latest one that exists in our branch as being the head of
# upstream.
best_guess_for_head=""
candidates=`git reflog --no-abbrev-commit | grep " to $upstream_branch" | cut -d" " -f1`
candidates=`git reflog --no-abbrev-commit | grep " to $upstream_branch$" | cut -d" " -f1`
for commit in $candidates; do
if [ `git merge-base "$commit" HEAD` = "$commit" ]; then
# It's in our branch! So this is our winner unless we've
Expand Down

0 comments on commit 8d3b906

Please sign in to comment.