Skip to content

Commit e02cf70

Browse files
authored
Merge pull request #3 from XanClic/master
git-backport-diff: Default to newest commit
2 parents d8ee7c3 + d0c8cbd commit e02cf70

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

git-backport-diff

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,19 @@ compare_git()
228228
subj=${hashsubj:40}
229229
downhash=${hashsubj:0:40}
230230
# A little bit hackish, but find the match by looking at upstream
231-
# subject lines, and using the last one. Not all backports contain
231+
# subject lines, and using the newest one. Not all backports contain
232232
# the phrase "cherry-pick", so we can't really try and find the
233233
# upstream hash from that...
234-
uphash=`git log $upstream --pretty=format:"%H" --fixed-strings --grep="${subj}" |tail -n 1`
234+
uphash=""
235+
while read uphashsubj
236+
do
237+
if [[ "${uphashsubj:40}" == "$subj" ]]
238+
then
239+
uphash=${uphashsubj:0:40}
240+
break
241+
fi
242+
done < <(git log $upstream --pretty=tformat:"%H%s" --fixed-strings --grep="${subj}")
243+
235244
if [[ -n "$uphash" ]]
236245
then
237246
numdiff=`diff -u <(git diff $uphash^! |egrep ^[-+])\

0 commit comments

Comments
 (0)