diff.c: return filepair from diff_unmerge()
The underlying diff_queue() returns diff_filepair so that the caller can further add information to it, and the helper function diff_unmerge() utilizes the feature itself, but does not expose it to its callers, which was kind of selfish. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Apr 22, 2011 at 15:55 UTC
76399c0195278ed2b52716b821cf064f77131736
2 files changed
+9
-6
diff.c
+8
-5
@@ -4308,20 +4308,23 @@ void diff_change(struct diff_options *options,
4308
DIFF_OPT_SET(options, HAS_CHANGES);
4309
}
4310
4311
-void diff_unmerge(struct diff_options *options,
4312
- const char *path,
4313
- unsigned mode, const unsigned char *sha1)
4311
+struct diff_filepair *diff_unmerge(struct diff_options *options,
4312
+ const char *path,
4313
+ unsigned mode, const unsigned char *sha1)
4314
{
4315
+ struct diff_filepair *pair;
4316
struct diff_filespec *one, *two;
4317
4318
if (options->prefix &&
4319
strncmp(path, options->prefix, options->prefix_length))
4319
- return;
4320
+ return NULL;
4321
4322
one = alloc_filespec(path);
4323
two = alloc_filespec(path);
4324
fill_filespec(one, sha1, mode);
4324
- diff_queue(&diff_queued_diff, one, two)->is_unmerged = 1;
4325
+ pair = diff_queue(&diff_queued_diff, one, two);
4326
+ pair->is_unmerged = 1;
4327
+ return pair;
4328
}
4329
4330
static char *run_textconv(const char *pgm, struct diff_filespec *spec,
diff.h
+1
-1
@@ -209,7 +209,7 @@ extern void diff_change(struct diff_options *,
209
const char *fullpath,
210
unsigned dirty_submodule1, unsigned dirty_submodule2);
211
212
-extern void diff_unmerge(struct diff_options *,
212
+extern struct diff_filepair *diff_unmerge(struct diff_options *,
213
const char *path,
214
unsigned mode,
215
const unsigned char *sha1);