git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [PATCH] diff.c: Fix whitespace issues due to a mismerge(?)
Date: Mon,  8 May 2017 11:43:54 -0700	[thread overview]
Message-ID: <20170508184354.31671-1-sbeller@google.com> (raw)

Re-indent lines, as they were off by one.
When a line was not indented (as you would expect from function defintions)
we had a stray whitespace preceding the line.
Indented lines have a stray white space after the indentation by tabs,
before the actual text, i.e.

<TAB><WS>if (...)
<TAB><TAB><WS>...

It looks like all these lines were introduced by one of the conflict chunks
in 4af9a7d344 (Merge branch 'bc/object-id', 2016-09-19). Viewing that
commit in gitk, the indentation seems fine, i.e. there is just one
whitespace in front of the lines, as you would expect from a formatted
patch.

Signed-off-by: Stefan Beller <sbeller@google.com>
---

 Junio, 
 I do not think it is worth to apply this patch on its own,
 but maybe it is worth to investigate your setup? (Assuming it is
 git that did the merge, we may have a bug in whitespacing and
 merge conflicts.)
 
 Thanks,
 Stefan

 apply.c | 310 ++++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 155 insertions(+), 155 deletions(-)

diff --git a/apply.c b/apply.c
index e6dbab26ad..be340991d7 100644
--- a/apply.c
+++ b/apply.c
@@ -4098,172 +4098,172 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
 	 return 0;
  }
 
- static void stat_patch_list(struct apply_state *state, struct patch *patch)
- {
-	 int files, adds, dels;
-
-	 for (files = adds = dels = 0 ; patch ; patch = patch->next) {
-		 files++;
-		 adds += patch->lines_added;
-		 dels += patch->lines_deleted;
-		 show_stats(state, patch);
-	 }
-
-	 print_stat_summary(stdout, files, adds, dels);
- }
+static void stat_patch_list(struct apply_state *state, struct patch *patch)
+{
+	int files, adds, dels;
 
- static void numstat_patch_list(struct apply_state *state,
+	for (files = adds = dels = 0 ; patch ; patch = patch->next) {
+		files++;
+		adds += patch->lines_added;
+		dels += patch->lines_deleted;
+		show_stats(state, patch);
+	}
+
+	print_stat_summary(stdout, files, adds, dels);
+}
+
+static void numstat_patch_list(struct apply_state *state,
 				struct patch *patch)
- {
-	 for ( ; patch; patch = patch->next) {
-		 const char *name;
-		 name = patch->new_name ? patch->new_name : patch->old_name;
-		 if (patch->is_binary)
-			 printf("-\t-\t");
-		 else
-			 printf("%d\t%d\t", patch->lines_added, patch->lines_deleted);
-		 write_name_quoted(name, stdout, state->line_termination);
-	 }
- }
+{
+	for ( ; patch; patch = patch->next) {
+		const char *name;
+		name = patch->new_name ? patch->new_name : patch->old_name;
+		if (patch->is_binary)
+			printf("-\t-\t");
+		else
+			printf("%d\t%d\t", patch->lines_added, patch->lines_deleted);
+		write_name_quoted(name, stdout, state->line_termination);
+	}
+}
 
- static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)
- {
-	 if (mode)
-		 printf(" %s mode %06o %s\n", newdelete, mode, name);
+static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)
+{
+	if (mode)
+		printf(" %s mode %06o %s\n", newdelete, mode, name);
 	 else
-		 printf(" %s %s\n", newdelete, name);
- }
+		printf(" %s %s\n", newdelete, name);
+}
 
- static void show_mode_change(struct patch *p, int show_name)
- {
-	 if (p->old_mode && p->new_mode && p->old_mode != p->new_mode) {
-		 if (show_name)
-			 printf(" mode change %06o => %06o %s\n",
+static void show_mode_change(struct patch *p, int show_name)
+{
+	if (p->old_mode && p->new_mode && p->old_mode != p->new_mode) {
+		if (show_name)
+			printf(" mode change %06o => %06o %s\n",
 				p->old_mode, p->new_mode, p->new_name);
-		 else
-			 printf(" mode change %06o => %06o\n",
-				p->old_mode, p->new_mode);
-	 }
- }
+		else
+			printf(" mode change %06o => %06o\n",
+			       p->old_mode, p->new_mode);
+	}
+}
 
- static void show_rename_copy(struct patch *p)
- {
-	 const char *renamecopy = p->is_rename ? "rename" : "copy";
-	 const char *old, *new;
-
-	 /* Find common prefix */
-	 old = p->old_name;
-	 new = p->new_name;
-	 while (1) {
-		 const char *slash_old, *slash_new;
-		 slash_old = strchr(old, '/');
-		 slash_new = strchr(new, '/');
-		 if (!slash_old ||
-		     !slash_new ||
-		     slash_old - old != slash_new - new ||
-		     memcmp(old, new, slash_new - new))
-			 break;
-		 old = slash_old + 1;
-		 new = slash_new + 1;
-	 }
-	 /* p->old_name thru old is the common prefix, and old and new
-	  * through the end of names are renames
-	  */
-	 if (old != p->old_name)
-		 printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
-			(int)(old - p->old_name), p->old_name,
-			old, new, p->score);
-	 else
-		 printf(" %s %s => %s (%d%%)\n", renamecopy,
-			p->old_name, p->new_name, p->score);
-	 show_mode_change(p, 0);
- }
+static void show_rename_copy(struct patch *p)
+{
+	const char *renamecopy = p->is_rename ? "rename" : "copy";
+	const char *old, *new;
 
- static void summary_patch_list(struct patch *patch)
- {
-	 struct patch *p;
-
-	 for (p = patch; p; p = p->next) {
-		 if (p->is_new)
-			 show_file_mode_name("create", p->new_mode, p->new_name);
-		 else if (p->is_delete)
-			 show_file_mode_name("delete", p->old_mode, p->old_name);
-		 else {
-			 if (p->is_rename || p->is_copy)
-				 show_rename_copy(p);
-			 else {
-				 if (p->score) {
-					 printf(" rewrite %s (%d%%)\n",
-						p->new_name, p->score);
-					 show_mode_change(p, 0);
-				 }
-				 else
-					 show_mode_change(p, 1);
-			 }
-		 }
-	 }
- }
+	/* Find common prefix */
+	old = p->old_name;
+	new = p->new_name;
+	while (1) {
+		const char *slash_old, *slash_new;
+		slash_old = strchr(old, '/');
+		slash_new = strchr(new, '/');
+		if (!slash_old ||
+		    !slash_new ||
+		    slash_old - old != slash_new - new ||
+		    memcmp(old, new, slash_new - new))
+			break;
+		old = slash_old + 1;
+		new = slash_new + 1;
+	}
+	/* p->old_name thru old is the common prefix, and old and new
+	 * through the end of names are renames
+	 */
+	if (old != p->old_name)
+		printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
+		       (int)(old - p->old_name), p->old_name,
+		       old, new, p->score);
+	else
+		printf(" %s %s => %s (%d%%)\n", renamecopy,
+		       p->old_name, p->new_name, p->score);
+	show_mode_change(p, 0);
+}
 
- static void patch_stats(struct apply_state *state, struct patch *patch)
- {
-	 int lines = patch->lines_added + patch->lines_deleted;
-
-	 if (lines > state->max_change)
-		 state->max_change = lines;
-	 if (patch->old_name) {
-		 int len = quote_c_style(patch->old_name, NULL, NULL, 0);
-		 if (!len)
-			 len = strlen(patch->old_name);
-		 if (len > state->max_len)
-			 state->max_len = len;
-	 }
-	 if (patch->new_name) {
-		 int len = quote_c_style(patch->new_name, NULL, NULL, 0);
-		 if (!len)
-			 len = strlen(patch->new_name);
-		 if (len > state->max_len)
-			 state->max_len = len;
-	 }
- }
+static void summary_patch_list(struct patch *patch)
+{
+	struct patch *p;
 
- static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)
- {
-	 if (state->update_index) {
-		 if (remove_file_from_cache(patch->old_name) < 0)
-			 return error(_("unable to remove %s from index"), patch->old_name);
-	 }
-	 if (!state->cached) {
-		 if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
-			 remove_path(patch->old_name);
-		 }
-	 }
-	 return 0;
- }
+	for (p = patch; p; p = p->next) {
+		if (p->is_new)
+			show_file_mode_name("create", p->new_mode, p->new_name);
+		else if (p->is_delete)
+			show_file_mode_name("delete", p->old_mode, p->old_name);
+		else {
+			if (p->is_rename || p->is_copy)
+				show_rename_copy(p);
+			else {
+				if (p->score) {
+					printf(" rewrite %s (%d%%)\n",
+					       p->new_name, p->score);
+					show_mode_change(p, 0);
+				}
+				else
+					show_mode_change(p, 1);
+			}
+		}
+	}
+}
 
- static int add_index_file(struct apply_state *state,
-			   const char *path,
-			   unsigned mode,
-			   void *buf,
-			   unsigned long size)
- {
-	 struct stat st;
-	 struct cache_entry *ce;
-	 int namelen = strlen(path);
-	 unsigned ce_size = cache_entry_size(namelen);
-
-	 if (!state->update_index)
-		 return 0;
-
-	 ce = xcalloc(1, ce_size);
-	 memcpy(ce->name, path, namelen);
-	 ce->ce_mode = create_ce_mode(mode);
-	 ce->ce_flags = create_ce_flags(0);
-	 ce->ce_namelen = namelen;
-	 if (S_ISGITLINK(mode)) {
-		 const char *s;
-
-		 if (!skip_prefix(buf, "Subproject commit ", &s) ||
-		     get_oid_hex(s, &ce->oid)) {
+static void patch_stats(struct apply_state *state, struct patch *patch)
+{
+	int lines = patch->lines_added + patch->lines_deleted;
+
+	if (lines > state->max_change)
+		state->max_change = lines;
+	if (patch->old_name) {
+		int len = quote_c_style(patch->old_name, NULL, NULL, 0);
+		if (!len)
+			len = strlen(patch->old_name);
+		if (len > state->max_len)
+			state->max_len = len;
+	}
+	if (patch->new_name) {
+		int len = quote_c_style(patch->new_name, NULL, NULL, 0);
+		if (!len)
+			len = strlen(patch->new_name);
+		if (len > state->max_len)
+			state->max_len = len;
+	}
+}
+
+static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)
+{
+	if (state->update_index) {
+		if (remove_file_from_cache(patch->old_name) < 0)
+			return error(_("unable to remove %s from index"), patch->old_name);
+	}
+	if (!state->cached) {
+		if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
+			remove_path(patch->old_name);
+		}
+	}
+	return 0;
+}
+
+static int add_index_file(struct apply_state *state,
+			  const char *path,
+			  unsigned mode,
+			  void *buf,
+			  unsigned long size)
+{
+	struct stat st;
+	struct cache_entry *ce;
+	int namelen = strlen(path);
+	unsigned ce_size = cache_entry_size(namelen);
+
+	if (!state->update_index)
+		return 0;
+
+	ce = xcalloc(1, ce_size);
+	memcpy(ce->name, path, namelen);
+	ce->ce_mode = create_ce_mode(mode);
+	ce->ce_flags = create_ce_flags(0);
+	ce->ce_namelen = namelen;
+	if (S_ISGITLINK(mode)) {
+		const char *s;
+
+		if (!skip_prefix(buf, "Subproject commit ", &s) ||
+		    get_oid_hex(s, &ce->oid)) {
 			free(ce);
 			return error(_("corrupt patch for submodule %s"), path);
 		}
-- 
2.13.0.rc2.17.g46b64dc68a


             reply	other threads:[~2017-05-08 18:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 18:43 Stefan Beller [this message]
2017-05-09  2:06 ` [PATCH] diff.c: Fix whitespace issues due to a mismerge(?) Junio C Hamano
2017-05-09  2:38   ` 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=20170508184354.31671-1-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).