aboutsummaryrefslogtreecommitdiff
path: root/builtin/revert.c
diff options
context:
space:
mode:
authorJay Soffian <jaysoffian@gmail.com>2011-02-19 23:12:29 -0500
committerJunio C Hamano <gitster@pobox.com>2011-02-21 22:58:32 -0800
commit37f7a8579363a98efc48dfb6964a519034fc9acc (patch)
tree0fc435a0e27b66668cfd5bab3e08112ecdcecc4c /builtin/revert.c
parent5b2af8cac9883ab7e666d4aa30ea7fd3d1f1d4de (diff)
downloadgit-37f7a8579363a98efc48dfb6964a519034fc9acc.tar.gz
git-37f7a8579363a98efc48dfb6964a519034fc9acc.tar.xz
Teach commit about CHERRY_PICK_HEAD
Previously the user was advised to use commit -c CHERRY_PICK_HEAD after a conflicting cherry-pick. While this would preserve the original commit's authorship, it would sadly discard cherry-pick's carefully crafted MERGE_MSG (which contains the list of conflicts as well as the original commit-id in the case of cherry-pick -x). On the other hand, if a bare 'commit' were performed, it would preserve the MERGE_MSG while resetting the authorship. In other words, there was no way to simultaneously take the authorship from CHERRY_PICK_HEAD and the commit message from MERGE_MSG. This change fixes that situation. A bare 'commit' will now take the authorship from CHERRY_PICK_HEAD and the commit message from MERGE_MSG. If the user wishes to reset authorship, that must now be done explicitly via --reset-author. A side-benefit of passing commit authorship along this way is that we can eliminate redundant authorship parsing code from revert.c. (Also removed an unused include from revert.c) Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/revert.c')
-rw-r--r--builtin/revert.c56
1 files changed, 1 insertions, 55 deletions
diff --git a/builtin/revert.c b/builtin/revert.c
index e716a1b00..b3a3201c4 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -3,7 +3,6 @@
#include "object.h"
#include "commit.h"
#include "tag.h"
-#include "wt-status.h"
#include "run-command.h"
#include "exec_cmd.h"
#include "utf8.h"
@@ -181,56 +180,6 @@ static void add_message_to_msg(struct strbuf *msgbuf, const char *message)
strbuf_addstr(msgbuf, p);
}
-static void set_author_ident_env(const char *message)
-{
- const char *p = message;
- if (!p)
- die ("Could not read commit message of %s",
- sha1_to_hex(commit->object.sha1));
- while (*p && *p != '\n') {
- const char *eol;
-
- for (eol = p; *eol && *eol != '\n'; eol++)
- ; /* do nothing */
- if (!prefixcmp(p, "author ")) {
- char *line, *pend, *email, *timestamp;
-
- p += 7;
- line = xmemdupz(p, eol - p);
- email = strchr(line, '<');
- if (!email)
- die ("Could not extract author email from %s",
- sha1_to_hex(commit->object.sha1));
- if (email == line)
- pend = line;
- else
- for (pend = email; pend != line + 1 &&
- isspace(pend[-1]); pend--);
- ; /* do nothing */
- *pend = '\0';
- email++;
- timestamp = strchr(email, '>');
- if (!timestamp)
- die ("Could not extract author time from %s",
- sha1_to_hex(commit->object.sha1));
- *timestamp = '\0';
- for (timestamp++; *timestamp && isspace(*timestamp);
- timestamp++)
- ; /* do nothing */
- setenv("GIT_AUTHOR_NAME", line, 1);
- setenv("GIT_AUTHOR_EMAIL", email, 1);
- setenv("GIT_AUTHOR_DATE", timestamp, 1);
- free(line);
- return;
- }
- p = eol;
- if (*p == '\n')
- p++;
- }
- die ("No author information found in %s",
- sha1_to_hex(commit->object.sha1));
-}
-
static void write_cherry_pick_head(void)
{
int fd;
@@ -273,9 +222,7 @@ static void print_advice(void)
advise("after resolving the conflicts, mark the corrected paths");
advise("with 'git add <paths>' or 'git rm <paths>'");
-
- if (action == CHERRY_PICK)
- advise("and commit the result with 'git commit -c CHERRY_PICK_HEAD'");
+ advise("and commit the result with 'git commit'");
}
static void write_message(struct strbuf *msgbuf, const char *filename)
@@ -503,7 +450,6 @@ static int do_pick_commit(void)
base_label = msg.parent_label;
next = commit;
next_label = msg.label;
- set_author_ident_env(msg.message);
add_message_to_msg(&msgbuf, msg.message);
if (no_replay) {
strbuf_addstr(&msgbuf, "(cherry picked from commit ");