From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Thomas Rast <trast@student.ethz.ch>, Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH 1/2] git-format-patch: Print a diagnostic message when ignoring commits
Date: Sun, 22 Aug 2010 01:58:50 +0530 [thread overview]
Message-ID: <1282422531-29673-2-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1282422531-29673-1-git-send-email-artagnon@gmail.com>
Earlier, git-format-patch used to silently skip over commits that it
didn't intend to make patches out of. As a consequence, a command like
'git-format-patch -3' would just do nothing and print nothing if the
topmost three commits were merge commits. Instead, print a useful
message similar to "Skipping: Merge branch ..." when ignoring a
commit.
Suggested-by: Jakub Narebski <jnareb@gmail.com>
Cc: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
builtin/log.c | 42 +++++++++++++++++++++++++++++++-----------
1 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index 0151d2f..b64de7c 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1090,7 +1090,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
struct commit **list = NULL;
struct rev_info rev;
struct setup_revision_opt s_r_opt;
- int nr = 0, total, i;
+ int nr = 0, nr_i = 0, total, i;
int use_stdout = 0;
int start_number = -1;
int numbered_files = 0; /* _just_ numbers */
@@ -1098,6 +1098,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
int cover_letter = 0;
int boundary_count = 0;
int no_binary_diff = 0;
+ int *list_i = NULL;
struct commit *origin = NULL, *head = NULL;
const char *in_reply_to = NULL;
struct patch_ids ids;
@@ -1342,19 +1343,22 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
continue;
}
- /* ignore merges */
- if (commit->parents && commit->parents->next)
- continue;
-
- if (ignore_if_in_upstream &&
- has_commit_patch_id(commit, &ids))
- continue;
+ /* ignore merge commits and optionally ignore commits
+ already in upstream */
+ if ((commit->parents && commit->parents->next) ||
+ (ignore_if_in_upstream &&
+ has_commit_patch_id(commit, &ids))) {
+ /* Store the nr of the ignored commits in list_i */
+ nr_i++;
+ list_i = xrealloc(list_i, nr_i * sizeof(list_i[0]));
+ list_i[nr_i - 1] = nr;
+ }
nr++;
list = xrealloc(list, nr * sizeof(list[0]));
list[nr - 1] = commit;
}
- total = nr;
+ total = nr - nr_i;
if (!keep_subject && auto_number && total > 1)
numbered = 1;
if (numbered)
@@ -1376,10 +1380,25 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
start_number--;
}
rev.add_signoff = add_signoff;
- while (0 <= --nr) {
+ for (i = nr - nr_i; --nr >= 0;) {
int shown;
commit = list[nr];
- rev.nr = total - nr + (start_number - 1);
+
+ /* Ignore commits in list whose index is list_i */
+ if (list_i[nr_i - 1] == nr) {
+ struct strbuf commit_msg = STRBUF_INIT;
+ struct pretty_print_context ctx = {0};
+ format_commit_message(commit, "%s", &commit_msg, &ctx);
+ fprintf(realstdout, "Skipping: %s\n",
+ commit_msg.buf);
+ strbuf_release(&buf);
+ --nr_i;
+ continue;
+ }
+ else
+ --i;
+
+ rev.nr = total - i + (start_number - 1);
/* Make the second and subsequent mails replies to the first */
if (thread) {
/* Have we already had a message ID? */
@@ -1443,6 +1462,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
fclose(stdout);
}
free(list);
+ free(list_i);
string_list_clear(&extra_to, 0);
string_list_clear(&extra_cc, 0);
string_list_clear(&extra_hdr, 0);
--
1.7.2.2.409.gdbb11.dirty
next prev parent reply other threads:[~2010-08-21 20:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-21 20:28 [PATCH 0/2] log/ format-patch improvements Ramkumar Ramachandra
2010-08-21 20:28 ` Ramkumar Ramachandra [this message]
2010-08-21 20:28 ` [PATCH 2/2] log: Improve description of '-<n>' option in documentation Ramkumar Ramachandra
2010-08-25 8:44 ` [PATCH 0/2] log/ format-patch improvements Ramkumar Ramachandra
2010-08-25 20:54 ` Jonathan Nieder
2010-08-26 5:34 ` Ramkumar Ramachandra
2010-08-26 5:46 ` Jonathan Nieder
2010-08-26 7:06 ` Thomas Rast
2010-08-26 15:37 ` Junio C Hamano
2010-08-26 17:52 ` Ramkumar Ramachandra
2010-08-25 22:09 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1282422531-29673-2-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
--cc=trast@student.ethz.ch \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).