From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org
Cc: Jay Soffian <jaysoffian@gmail.com>
Subject: [RFC/PATCH 1/2] Introduce CHERRY_HEAD
Date: Tue, 15 Feb 2011 16:23:53 -0500 [thread overview]
Message-ID: <1297805034-3512-2-git-send-email-jaysoffian@gmail.com> (raw)
In-Reply-To: <1297805034-3512-1-git-send-email-jaysoffian@gmail.com>
When a cherry-pick conflicts git advises to use:
$ git commit -c <original commit id>
to preserve the original commit message and authorship. Instead,
let's record the original commit id in CHERRY_HEAD and advise to use:
$ git commit -c CHERRY_HEAD
In the next commit, we teach git to handle the '-c CHERRY_HEAD' part.
---
branch.c | 1 +
builtin/commit.c | 1 +
builtin/revert.c | 23 ++++++++++++++++++++---
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/branch.c b/branch.c
index 93dc866..81bbf95 100644
--- a/branch.c
+++ b/branch.c
@@ -217,6 +217,7 @@ void create_branch(const char *head,
void remove_branch_state(void)
{
+ unlink(git_path("CHERRY_HEAD"));
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_RR"));
unlink(git_path("MERGE_MSG"));
diff --git a/builtin/commit.c b/builtin/commit.c
index 03cff5a..8850621 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1424,6 +1424,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
die("cannot update HEAD ref");
}
+ unlink(git_path("CHERRY_HEAD"));
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_MSG"));
unlink(git_path("MERGE_MODE"));
diff --git a/builtin/revert.c b/builtin/revert.c
index dc1b702..c373e69 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -248,6 +248,22 @@ static void set_author_ident_env(const char *message)
sha1_to_hex(commit->object.sha1));
}
+static void write_cherry_head(void)
+{
+ int fd;
+ struct strbuf buf = STRBUF_INIT;
+
+ strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1));
+
+ fd = open(git_path("CHERRY_HEAD"), O_WRONLY | O_CREAT, 0666);
+ if (fd < 0)
+ die_errno("Could not open '%s' for writing",
+ git_path("CHERRY_HEAD"));
+ if (write_in_full(fd, buf.buf, buf.len) != buf.len)
+ die_errno("Could not write to '%s'", git_path("CHERRY_HEAD"));
+ close(fd);
+}
+
static void advise(const char *advice, ...)
{
va_list params;
@@ -269,9 +285,10 @@ 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 %s'",
- find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
+ if (action == CHERRY_PICK) {
+ write_cherry_head();
+ advise("and commit the result with 'git commit -c CHERRY_HEAD'");
+ }
}
static void write_message(struct strbuf *msgbuf, const char *filename)
--
1.7.4.5.g9affb
next prev parent reply other threads:[~2011-02-15 21:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-15 21:23 [RFC/PATCH 0/2] CHERRY_HEAD Jay Soffian
2011-02-15 21:23 ` Jay Soffian [this message]
2011-02-15 22:13 ` [RFC/PATCH 1/2] Introduce CHERRY_HEAD Junio C Hamano
2011-02-15 22:18 ` Jonathan Nieder
2011-02-15 22:59 ` Junio C Hamano
2011-02-15 23:02 ` Bert Wesarg
2011-02-15 23:10 ` Junio C Hamano
2011-02-15 23:42 ` Bert Wesarg
2011-02-15 23:07 ` Jay Soffian
2011-02-15 23:08 ` Jonathan Nieder
2011-02-15 21:23 ` [RFC/PATCH 2/2] Teach commit to handle CHERRY_HEAD automatically Jay Soffian
2011-02-15 22:16 ` Jay Soffian
2011-02-15 22:34 ` Junio C Hamano
2011-02-15 23:00 ` Jonathan Nieder
2011-02-15 23:21 ` Jay Soffian
2011-02-15 23:47 ` Jonathan Nieder
2011-02-16 0:03 ` Jay Soffian
2011-02-16 0:08 ` Jonathan Nieder
2011-02-16 0:05 ` [PATCH] Documentation: clarify interaction of --reset-author with --author Jonathan Nieder
2011-02-16 1:04 ` Junio C Hamano
2011-02-15 21:51 ` [RFC/PATCH 0/2] CHERRY_HEAD Ævar Arnfjörð Bjarmason
2011-02-15 22:10 ` Junio C Hamano
2011-02-15 22:13 ` Jay Soffian
2011-02-15 22:30 ` Ævar Arnfjörð Bjarmason
2011-02-15 22:11 ` Jay Soffian
2011-02-16 1:48 ` Miles Bader
2011-02-17 14:09 ` Christian Couder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1297805034-3512-2-git-send-email-jaysoffian@gmail.com \
--to=jaysoffian@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.