apply.c: fix whitespace-only mismerge
4af9a7d3 ("Merge branch 'bc/object-id'", 2016-09-19) involved merging a lot of changes made to builtin/apply.c on the side branch manually to apply.c as an intervening commit 13b5af22 ("apply: move libified code from builtin/apply.c to apply.{c,h}", 2016-04-22) moved a lot of the lines changed on the side branch to a different file apply.c at the top-level, requiring manual patching of it. Apparently, the maintainer screwed up and made the code indent in a funny way while doing so. Reported-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 8, 2017 at 19:30 UTC
e294e8959fea043225a023f981121540b14b08cd
1 file changed
+169
-169
apply.c
+169
-169
@@ -4091,181 +4091,181 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
4091
res = write_locked_index(&result, &lock, COMMIT_LOCK);
4092
discard_index(&result);
4093
4094
- if (res)
4095
- return error(_("could not write temporary index to %s"),
4096
- state->fake_ancestor);
4094
+ if (res)
4095
+ return error(_("could not write temporary index to %s"),
4096
+ state->fake_ancestor);
4097
4098
- return 0;
4099
- }
4098
+ return 0;
4099
+}
4100
4101
- static void stat_patch_list(struct apply_state *state, struct patch *patch)
4102
- {
4103
- int files, adds, dels;
4101
+static void stat_patch_list(struct apply_state *state, struct patch *patch)
4102
+{
4103
+ int files, adds, dels;
4104
4105
- for (files = adds = dels = 0 ; patch ; patch = patch->next) {
4106
- files++;
4107
- adds += patch->lines_added;
4108
- dels += patch->lines_deleted;
4109
- show_stats(state, patch);
4110
- }
4105
+ for (files = adds = dels = 0 ; patch ; patch = patch->next) {
4106
+ files++;
4107
+ adds += patch->lines_added;
4108
+ dels += patch->lines_deleted;
4109
+ show_stats(state, patch);
4110
+ }
4111
4112
- print_stat_summary(stdout, files, adds, dels);
4113
- }
4112
+ print_stat_summary(stdout, files, adds, dels);
4113
+}
4114
4115
- static void numstat_patch_list(struct apply_state *state,
4116
- struct patch *patch)
4117
- {
4118
- for ( ; patch; patch = patch->next) {
4119
- const char *name;
4120
- name = patch->new_name ? patch->new_name : patch->old_name;
4121
- if (patch->is_binary)
4122
- printf("-\t-\t");
4123
- else
4124
- printf("%d\t%d\t", patch->lines_added, patch->lines_deleted);
4125
- write_name_quoted(name, stdout, state->line_termination);
4126
- }
4127
- }
4128
-
4129
- static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)
4130
- {
4131
- if (mode)
4132
- printf(" %s mode %06o %s\n", newdelete, mode, name);
4133
- else
4134
- printf(" %s %s\n", newdelete, name);
4135
- }
4136
-
4137
- static void show_mode_change(struct patch *p, int show_name)
4138
- {
4139
- if (p->old_mode && p->new_mode && p->old_mode != p->new_mode) {
4140
- if (show_name)
4141
- printf(" mode change %06o => %06o %s\n",
4142
- p->old_mode, p->new_mode, p->new_name);
4143
- else
4144
- printf(" mode change %06o => %06o\n",
4145
- p->old_mode, p->new_mode);
4146
- }
4147
- }
4148
-
4149
- static void show_rename_copy(struct patch *p)
4150
- {
4151
- const char *renamecopy = p->is_rename ? "rename" : "copy";
4152
- const char *old, *new;
4153
-
4154
- /* Find common prefix */
4155
- old = p->old_name;
4156
- new = p->new_name;
4157
- while (1) {
4158
- const char *slash_old, *slash_new;
4159
- slash_old = strchr(old, '/');
4160
- slash_new = strchr(new, '/');
4161
- if (!slash_old ||
4162
- !slash_new ||
4163
- slash_old - old != slash_new - new ||
4164
- memcmp(old, new, slash_new - new))
4165
- break;
4166
- old = slash_old + 1;
4167
- new = slash_new + 1;
4168
- }
4169
- /* p->old_name thru old is the common prefix, and old and new
4170
- * through the end of names are renames
4171
- */
4172
- if (old != p->old_name)
4173
- printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
4174
- (int)(old - p->old_name), p->old_name,
4175
- old, new, p->score);
4176
- else
4177
- printf(" %s %s => %s (%d%%)\n", renamecopy,
4178
- p->old_name, p->new_name, p->score);
4179
- show_mode_change(p, 0);
4180
- }
4181
-
4182
- static void summary_patch_list(struct patch *patch)
4183
- {
4184
- struct patch *p;
4185
-
4186
- for (p = patch; p; p = p->next) {
4187
- if (p->is_new)
4188
- show_file_mode_name("create", p->new_mode, p->new_name);
4189
- else if (p->is_delete)
4190
- show_file_mode_name("delete", p->old_mode, p->old_name);
4191
- else {
4192
- if (p->is_rename || p->is_copy)
4193
- show_rename_copy(p);
4194
- else {
4195
- if (p->score) {
4196
- printf(" rewrite %s (%d%%)\n",
4197
- p->new_name, p->score);
4198
- show_mode_change(p, 0);
4199
- }
4200
- else
4201
- show_mode_change(p, 1);
4202
- }
4203
- }
4204
- }
4205
- }
4206
-
4207
- static void patch_stats(struct apply_state *state, struct patch *patch)
4208
- {
4209
- int lines = patch->lines_added + patch->lines_deleted;
4210
-
4211
- if (lines > state->max_change)
4212
- state->max_change = lines;
4213
- if (patch->old_name) {
4214
- int len = quote_c_style(patch->old_name, NULL, NULL, 0);
4215
- if (!len)
4216
- len = strlen(patch->old_name);
4217
- if (len > state->max_len)
4218
- state->max_len = len;
4219
- }
4220
- if (patch->new_name) {
4221
- int len = quote_c_style(patch->new_name, NULL, NULL, 0);
4222
- if (!len)
4223
- len = strlen(patch->new_name);
4224
- if (len > state->max_len)
4225
- state->max_len = len;
4226
- }
4227
- }
4228
-
4229
- static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)
4230
- {
4231
- if (state->update_index) {
4232
- if (remove_file_from_cache(patch->old_name) < 0)
4233
- return error(_("unable to remove %s from index"), patch->old_name);
4234
- }
4235
- if (!state->cached) {
4236
- if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
4237
- remove_path(patch->old_name);
4238
- }
4239
- }
4240
- return 0;
4241
- }
4242
-
4243
- static int add_index_file(struct apply_state *state,
4244
- const char *path,
4245
- unsigned mode,
4246
- void *buf,
4247
- unsigned long size)
4248
- {
4249
- struct stat st;
4250
- struct cache_entry *ce;
4251
- int namelen = strlen(path);
4252
- unsigned ce_size = cache_entry_size(namelen);
4253
-
4254
- if (!state->update_index)
4255
- return 0;
4256
-
4257
- ce = xcalloc(1, ce_size);
4258
- memcpy(ce->name, path, namelen);
4259
- ce->ce_mode = create_ce_mode(mode);
4260
- ce->ce_flags = create_ce_flags(0);
4261
- ce->ce_namelen = namelen;
4262
- if (S_ISGITLINK(mode)) {
4263
- const char *s;
4264
-
4265
- if (!skip_prefix(buf, "Subproject commit ", &s) ||
4266
- get_oid_hex(s, &ce->oid)) {
4115
+static void numstat_patch_list(struct apply_state *state,
4116
+ struct patch *patch)
4117
+{
4118
+ for ( ; patch; patch = patch->next) {
4119
+ const char *name;
4120
+ name = patch->new_name ? patch->new_name : patch->old_name;
4121
+ if (patch->is_binary)
4122
+ printf("-\t-\t");
4123
+ else
4124
+ printf("%d\t%d\t", patch->lines_added, patch->lines_deleted);
4125
+ write_name_quoted(name, stdout, state->line_termination);
4126
+ }
4127
+}
4128
+
4129
+static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)
4130
+{
4131
+ if (mode)
4132
+ printf(" %s mode %06o %s\n", newdelete, mode, name);
4133
+ else
4134
+ printf(" %s %s\n", newdelete, name);
4135
+}
4136
+
4137
+static void show_mode_change(struct patch *p, int show_name)
4138
+{
4139
+ if (p->old_mode && p->new_mode && p->old_mode != p->new_mode) {
4140
+ if (show_name)
4141
+ printf(" mode change %06o => %06o %s\n",
4142
+ p->old_mode, p->new_mode, p->new_name);
4143
+ else
4144
+ printf(" mode change %06o => %06o\n",
4145
+ p->old_mode, p->new_mode);
4146
+ }
4147
+}
4148
+
4149
+static void show_rename_copy(struct patch *p)
4150
+{
4151
+ const char *renamecopy = p->is_rename ? "rename" : "copy";
4152
+ const char *old, *new;
4153
+
4154
+ /* Find common prefix */
4155
+ old = p->old_name;
4156
+ new = p->new_name;
4157
+ while (1) {
4158
+ const char *slash_old, *slash_new;
4159
+ slash_old = strchr(old, '/');
4160
+ slash_new = strchr(new, '/');
4161
+ if (!slash_old ||
4162
+ !slash_new ||
4163
+ slash_old - old != slash_new - new ||
4164
+ memcmp(old, new, slash_new - new))
4165
+ break;
4166
+ old = slash_old + 1;
4167
+ new = slash_new + 1;
4168
+ }
4169
+ /* p->old_name thru old is the common prefix, and old and new
4170
+ * through the end of names are renames
4171
+ */
4172
+ if (old != p->old_name)
4173
+ printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
4174
+ (int)(old - p->old_name), p->old_name,
4175
+ old, new, p->score);
4176
+ else
4177
+ printf(" %s %s => %s (%d%%)\n", renamecopy,
4178
+ p->old_name, p->new_name, p->score);
4179
+ show_mode_change(p, 0);
4180
+}
4181
+
4182
+static void summary_patch_list(struct patch *patch)
4183
+{
4184
+ struct patch *p;
4185
+
4186
+ for (p = patch; p; p = p->next) {
4187
+ if (p->is_new)
4188
+ show_file_mode_name("create", p->new_mode, p->new_name);
4189
+ else if (p->is_delete)
4190
+ show_file_mode_name("delete", p->old_mode, p->old_name);
4191
+ else {
4192
+ if (p->is_rename || p->is_copy)
4193
+ show_rename_copy(p);
4194
+ else {
4195
+ if (p->score) {
4196
+ printf(" rewrite %s (%d%%)\n",
4197
+ p->new_name, p->score);
4198
+ show_mode_change(p, 0);
4199
+ }
4200
+ else
4201
+ show_mode_change(p, 1);
4202
+ }
4203
+ }
4204
+ }
4205
+}
4206
+
4207
+static void patch_stats(struct apply_state *state, struct patch *patch)
4208
+{
4209
+ int lines = patch->lines_added + patch->lines_deleted;
4210
+
4211
+ if (lines > state->max_change)
4212
+ state->max_change = lines;
4213
+ if (patch->old_name) {
4214
+ int len = quote_c_style(patch->old_name, NULL, NULL, 0);
4215
+ if (!len)
4216
+ len = strlen(patch->old_name);
4217
+ if (len > state->max_len)
4218
+ state->max_len = len;
4219
+ }
4220
+ if (patch->new_name) {
4221
+ int len = quote_c_style(patch->new_name, NULL, NULL, 0);
4222
+ if (!len)
4223
+ len = strlen(patch->new_name);
4224
+ if (len > state->max_len)
4225
+ state->max_len = len;
4226
+ }
4227
+}
4228
+
4229
+static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)
4230
+{
4231
+ if (state->update_index) {
4232
+ if (remove_file_from_cache(patch->old_name) < 0)
4233
+ return error(_("unable to remove %s from index"), patch->old_name);
4234
+ }
4235
+ if (!state->cached) {
4236
+ if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
4237
+ remove_path(patch->old_name);
4238
+ }
4239
+ }
4240
+ return 0;
4241
+}
4242
+
4243
+static int add_index_file(struct apply_state *state,
4244
+ const char *path,
4245
+ unsigned mode,
4246
+ void *buf,
4247
+ unsigned long size)
4248
+{
4249
+ struct stat st;
4250
+ struct cache_entry *ce;
4251
+ int namelen = strlen(path);
4252
+ unsigned ce_size = cache_entry_size(namelen);
4253
+
4254
+ if (!state->update_index)
4255
+ return 0;
4256
+
4257
+ ce = xcalloc(1, ce_size);
4258
+ memcpy(ce->name, path, namelen);
4259
+ ce->ce_mode = create_ce_mode(mode);
4260
+ ce->ce_flags = create_ce_flags(0);
4261
+ ce->ce_namelen = namelen;
4262
+ if (S_ISGITLINK(mode)) {
4263
+ const char *s;
4264
+
4265
+ if (!skip_prefix(buf, "Subproject commit ", &s) ||
4266
+ get_oid_hex(s, &ce->oid)) {
4267
free(ce);
4268
- return error(_("corrupt patch for submodule %s"), path);
4268
+ return error(_("corrupt patch for submodule %s"), path);
4269
}
4270
} else {
4271
if (!state->cached) {