path: root/git-compat-util.h
diff options
authorJunio C Hamano <>2007-10-23 20:33:26 (GMT)
committerJunio C Hamano <>2007-10-27 06:28:28 (GMT)
commit7791ecbc62b792b3eaa6d722b6dadcea4d0f322d (patch)
tree08ff76b3a227d4bc0395473ad103e82a00355ea3 /git-compat-util.h
parent85b00455057c19a993eeaee2606af550b8d4de10 (diff)
revert/cherry-pick: work on merge commits as well
Usually you cannot revert a merge because you do not know which side of the merge should be considered the mainline (iow, what change to reverse). With this patch, cherry-pick and revert learn -m (--mainline) option that lets you specify the parent number (starting from 1) of the mainline, so that you can: git revert -m 1 $merge to reverse the changes introduced by the $merge commit relative to its first parent, and: git cherry-pick -m 2 $merge to replay the changes introduced by the $merge commit relative to its second parent. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'git-compat-util.h')
1 files changed, 13 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 474f1d1..7b29d1b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -381,4 +381,17 @@ static inline int strtoul_ui(char const *s, int base, unsigned int *result)
return 0;
+static inline int strtol_i(char const *s, int base, int *result)
+ long ul;
+ char *p;
+ errno = 0;
+ ul = strtol(s, &p, base);
+ if (errno || *p || p == s || (int) ul != ul)
+ return -1;
+ *result = ul;
+ return 0;