From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 3/3] commit-tree: teach -x <extra>
Date: Wed, 9 Nov 2011 13:01:35 -0800 [thread overview]
Message-ID: <1320872495-7545-4-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1320872495-7545-1-git-send-email-gitster@pobox.com>
By feeding the header part of the original commit with this parameter,
e.g. -x "$(git cat-file commit $commit | sed -n -e /^$/q -e p)", extra
headers of another commit can be transplanted to the resulting commit.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/git-commit-tree.txt | 3 ++-
builtin/commit-tree.c | 20 ++++++++++++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt
index cfb9906..060e79d 100644
--- a/Documentation/git-commit-tree.txt
+++ b/Documentation/git-commit-tree.txt
@@ -10,7 +10,8 @@ SYNOPSIS
--------
[verse]
'git commit-tree' <tree> [(-p <parent>)...] < changelog
-'git commit-tree' [(-p <parent>)...] [(-m <message>)...] [(-F <file>)...] <tree>
+'git commit-tree' [(-p <parent>)...] [(-m <message>)...] [(-F <file>)...]
+ [(-x <extra>)...]<tree>
DESCRIPTION
-----------
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index db5b6e5..8b0a223 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -9,7 +9,7 @@
#include "builtin.h"
#include "utf8.h"
-static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-m <message>] <sha1> < changelog";
+static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-m <message>] [-x <extra>] <sha1> < changelog";
static void new_parent(struct commit *parent, struct commit_list **parents_p)
{
@@ -32,6 +32,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
unsigned char tree_sha1[20];
unsigned char commit_sha1[20];
struct strbuf buffer = STRBUF_INIT;
+ struct commit_extra_header *extra = NULL, **extra_tail = &extra;
git_config(git_default_config, NULL);
@@ -86,6 +87,20 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
continue;
}
+ if (!strcmp(arg, "-x")) {
+ struct commit_extra_header *x;
+ if (argc <= ++i)
+ usage(commit_tree_usage);
+ x = read_commit_extra_header_lines(argv[i], strlen(argv[i]));
+ if (x) {
+ *extra_tail = x;
+ while (x->next)
+ x = x->next;
+ extra_tail = &x->next;
+ }
+ continue;
+ }
+
if (get_sha1(arg, tree_sha1))
die("Not a valid object name %s", arg);
if (got_tree)
@@ -98,7 +113,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
die_errno("git commit-tree: failed to read");
}
- if (commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) {
+ if (commit_tree_extended(buffer.buf, tree_sha1, parents, commit_sha1,
+ NULL, extra)) {
strbuf_release(&buffer);
return 1;
}
--
1.7.8.rc1.82.gde0f9
next prev parent reply other threads:[~2011-11-09 21:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-09 21:01 [PATCH 0/3] commit-tree updates Junio C Hamano
2011-11-09 21:01 ` [PATCH 1/3] commit-tree: update the command line parsing Junio C Hamano
2011-11-09 21:01 ` [PATCH 2/3] commit-tree: teach -m/-F options to read logs from elsewhere Junio C Hamano
2011-11-09 21:01 ` Junio C Hamano [this message]
2011-11-09 22:19 ` [PATCH 3/3] commit-tree: teach -x <extra> Brad King
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=1320872495-7545-4-git-send-email-gitster@pobox.com \
--to=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).