2005-04-08 02:16:10 +04:00
|
|
|
/*
|
|
|
|
* GIT - The information manager from hell
|
|
|
|
*
|
|
|
|
* Copyright (C) Linus Torvalds, 2005
|
|
|
|
*/
|
2005-04-08 02:13:13 +04:00
|
|
|
#include "cache.h"
|
2005-04-27 20:21:00 +04:00
|
|
|
#include "diff.h"
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
#include "commit.h"
|
|
|
|
#include "revision.h"
|
2005-04-12 13:04:44 +04:00
|
|
|
|
2005-07-29 13:01:26 +04:00
|
|
|
static const char diff_files_usage[] =
|
2006-01-28 11:03:38 +03:00
|
|
|
"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
|
2005-07-13 23:52:35 +04:00
|
|
|
COMMON_DIFF_OPTIONS_HELP;
|
2005-04-17 08:29:45 +04:00
|
|
|
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
static struct rev_info rev;
|
2005-04-27 04:17:36 +04:00
|
|
|
static int silent = 0;
|
diff-files: show diffs with stage0 and unmerged stage at the same time.
After thinking about it more, I realized that much of the change
I did on top of Linus' version does not make much sense. This
commit reverts it so that it by default shows diffs with stage0
paths or stage2 paths with working tree; the unmerged stage to
use can be overridden with -1/-2/-3 option (-2 is the default so
essentially is a no-op).
When the index file is unmerged, we are by definition in the
middle of a conflicting merge, and we should show the diff with
stage 2 by default. More importantly, paths without conflicts
are updated in the working tree and collapsed to stage0 in the
index, so showing diff with stage0 at the same time does not
hurt. In normal cases, stage0 entries should be in sync with
the working tree files and does not clutter the output. It even
helps the user to realize that the working tree has local
changes unrelated to the merge and remember to be careful not to
do a "git-commit -a" after resolving the conflicts.
When there is no unmerged entries, giving diff_unmerged_stage a
default value of 2 does not cause any harm, because it would not
be used anyway. So in all, always showing diff between stage0
paths and unmerged entries from a stage (defaulting to 2) is the
right thing to do, as Linus originally did.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-30 13:16:36 +03:00
|
|
|
static int diff_unmerged_stage = 2;
|
2006-01-28 11:03:38 +03:00
|
|
|
static int combine_merges = 0;
|
|
|
|
static int dense_combined_merges = 0;
|
2005-04-27 04:17:36 +04:00
|
|
|
|
2005-04-27 20:21:00 +04:00
|
|
|
static void show_unmerge(const char *path)
|
2005-04-27 04:17:36 +04:00
|
|
|
{
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
diff_unmerge(&rev.diffopt, path);
|
2005-04-27 20:21:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void show_file(int pfx, struct cache_entry *ce)
|
|
|
|
{
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
diff_addremove(&rev.diffopt, pfx, ntohl(ce->ce_mode),
|
2005-09-21 11:00:47 +04:00
|
|
|
ce->sha1, ce->name, NULL);
|
2005-04-27 20:21:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void show_modified(int oldmode, int mode,
|
2005-05-18 16:14:09 +04:00
|
|
|
const unsigned char *old_sha1, const unsigned char *sha1,
|
2005-04-27 20:21:00 +04:00
|
|
|
char *path)
|
|
|
|
{
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
diff_change(&rev.diffopt, oldmode, mode, old_sha1, sha1, path, NULL);
|
2005-04-27 04:17:36 +04:00
|
|
|
}
|
|
|
|
|
2005-09-21 11:00:47 +04:00
|
|
|
int main(int argc, const char **argv)
|
2005-04-08 02:13:13 +04:00
|
|
|
{
|
2005-07-15 03:55:06 +04:00
|
|
|
const char **pathspec;
|
2005-08-17 05:06:34 +04:00
|
|
|
const char *prefix = setup_git_directory();
|
|
|
|
int entries, i;
|
2005-04-08 02:13:13 +04:00
|
|
|
|
2005-11-22 09:52:37 +03:00
|
|
|
git_config(git_diff_config);
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
diff_setup(&rev.diffopt);
|
2005-04-17 08:29:45 +04:00
|
|
|
while (1 < argc && argv[1][0] == '-') {
|
2005-10-18 11:16:45 +04:00
|
|
|
if (!strcmp(argv[1], "--")) {
|
|
|
|
argv++;
|
|
|
|
argc--;
|
|
|
|
break;
|
|
|
|
}
|
2005-11-30 08:06:10 +03:00
|
|
|
if (!strcmp(argv[1], "-0"))
|
|
|
|
diff_unmerged_stage = 0;
|
|
|
|
else if (!strcmp(argv[1], "-1"))
|
|
|
|
diff_unmerged_stage = 1;
|
|
|
|
else if (!strcmp(argv[1], "-2"))
|
|
|
|
diff_unmerged_stage = 2;
|
|
|
|
else if (!strcmp(argv[1], "-3"))
|
|
|
|
diff_unmerged_stage = 3;
|
|
|
|
else if (!strcmp(argv[1], "--base"))
|
|
|
|
diff_unmerged_stage = 1;
|
|
|
|
else if (!strcmp(argv[1], "--ours"))
|
|
|
|
diff_unmerged_stage = 2;
|
|
|
|
else if (!strcmp(argv[1], "--theirs"))
|
|
|
|
diff_unmerged_stage = 3;
|
|
|
|
else if (!strcmp(argv[1], "-q"))
|
2005-04-28 02:22:02 +04:00
|
|
|
silent = 1;
|
2005-04-27 04:17:36 +04:00
|
|
|
else if (!strcmp(argv[1], "-r"))
|
2005-04-27 20:21:00 +04:00
|
|
|
; /* no-op */
|
2005-04-28 02:22:02 +04:00
|
|
|
else if (!strcmp(argv[1], "-s"))
|
|
|
|
; /* no-op */
|
2006-01-28 11:03:38 +03:00
|
|
|
else if (!strcmp(argv[1], "-c"))
|
|
|
|
combine_merges = 1;
|
|
|
|
else if (!strcmp(argv[1], "--cc"))
|
|
|
|
dense_combined_merges = combine_merges = 1;
|
2005-09-21 11:00:47 +04:00
|
|
|
else {
|
|
|
|
int diff_opt_cnt;
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
diff_opt_cnt = diff_opt_parse(&rev.diffopt,
|
2005-09-21 11:00:47 +04:00
|
|
|
argv+1, argc-1);
|
|
|
|
if (diff_opt_cnt < 0)
|
2005-06-03 12:37:54 +04:00
|
|
|
usage(diff_files_usage);
|
2005-09-21 11:00:47 +04:00
|
|
|
else if (diff_opt_cnt) {
|
|
|
|
argv += diff_opt_cnt;
|
|
|
|
argc -= diff_opt_cnt;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
2005-06-03 12:37:54 +04:00
|
|
|
usage(diff_files_usage);
|
2005-05-21 13:39:09 +04:00
|
|
|
}
|
2005-04-17 08:29:45 +04:00
|
|
|
argv++; argc--;
|
2005-04-13 12:40:09 +04:00
|
|
|
}
|
2006-02-10 02:23:06 +03:00
|
|
|
if (dense_combined_merges)
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
|
2005-04-13 12:40:09 +04:00
|
|
|
|
2005-08-17 05:06:34 +04:00
|
|
|
/* Find the directory, and set up the pathspec */
|
|
|
|
pathspec = get_pathspec(prefix, argv + 1);
|
|
|
|
entries = read_cache();
|
2005-07-15 03:55:06 +04:00
|
|
|
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
if (diff_setup_done(&rev.diffopt) < 0)
|
2005-06-20 00:14:05 +04:00
|
|
|
usage(diff_files_usage);
|
|
|
|
|
2005-04-17 08:29:45 +04:00
|
|
|
/* At this point, if argc == 1, then we are doing everything.
|
|
|
|
* Otherwise argv[1] .. argv[argc-1] have the explicit paths.
|
|
|
|
*/
|
2005-04-08 02:13:13 +04:00
|
|
|
if (entries < 0) {
|
|
|
|
perror("read_cache");
|
|
|
|
exit(1);
|
|
|
|
}
|
2005-04-26 20:25:05 +04:00
|
|
|
|
2005-04-08 02:13:13 +04:00
|
|
|
for (i = 0; i < entries; i++) {
|
|
|
|
struct stat st;
|
2005-10-12 05:45:33 +04:00
|
|
|
unsigned int oldmode, newmode;
|
2005-04-08 02:13:13 +04:00
|
|
|
struct cache_entry *ce = active_cache[i];
|
2005-04-17 08:29:45 +04:00
|
|
|
int changed;
|
2005-04-08 02:13:13 +04:00
|
|
|
|
2005-07-15 03:55:06 +04:00
|
|
|
if (!ce_path_match(ce, pathspec))
|
|
|
|
continue;
|
|
|
|
|
2005-04-17 08:29:45 +04:00
|
|
|
if (ce_stage(ce)) {
|
2006-01-28 11:03:38 +03:00
|
|
|
struct {
|
|
|
|
struct combine_diff_path p;
|
2006-02-06 23:53:07 +03:00
|
|
|
struct combine_diff_parent filler[5];
|
2006-01-28 11:03:38 +03:00
|
|
|
} combine;
|
2006-01-28 13:09:08 +03:00
|
|
|
int num_compare_stages = 0;
|
2006-01-28 11:03:38 +03:00
|
|
|
|
|
|
|
combine.p.next = NULL;
|
|
|
|
combine.p.len = ce_namelen(ce);
|
|
|
|
combine.p.path = xmalloc(combine.p.len + 1);
|
|
|
|
memcpy(combine.p.path, ce->name, combine.p.len);
|
|
|
|
combine.p.path[combine.p.len] = 0;
|
2006-02-06 23:53:07 +03:00
|
|
|
combine.p.mode = 0;
|
|
|
|
memset(combine.p.sha1, 0, 20);
|
|
|
|
memset(&combine.p.parent[0], 0,
|
|
|
|
sizeof(combine.filler));
|
2006-01-28 11:03:38 +03:00
|
|
|
|
2005-11-30 08:06:10 +03:00
|
|
|
while (i < entries) {
|
|
|
|
struct cache_entry *nce = active_cache[i];
|
2006-01-28 11:03:38 +03:00
|
|
|
int stage;
|
2005-11-30 08:06:10 +03:00
|
|
|
|
|
|
|
if (strcmp(ce->name, nce->name))
|
|
|
|
break;
|
2006-01-28 11:03:38 +03:00
|
|
|
|
|
|
|
/* Stage #2 (ours) is the first parent,
|
|
|
|
* stage #3 (theirs) is the second.
|
|
|
|
*/
|
|
|
|
stage = ce_stage(nce);
|
2006-01-28 13:09:08 +03:00
|
|
|
if (2 <= stage) {
|
2006-02-06 23:53:07 +03:00
|
|
|
int mode = ntohl(nce->ce_mode);
|
2006-01-28 13:09:08 +03:00
|
|
|
num_compare_stages++;
|
2006-02-06 23:53:07 +03:00
|
|
|
memcpy(combine.p.parent[stage-2].sha1,
|
2006-01-28 11:03:38 +03:00
|
|
|
nce->sha1, 20);
|
2006-02-06 23:53:07 +03:00
|
|
|
combine.p.parent[stage-2].mode =
|
2006-03-30 10:55:43 +04:00
|
|
|
canon_mode(mode);
|
2006-02-14 12:11:42 +03:00
|
|
|
combine.p.parent[stage-2].status =
|
|
|
|
DIFF_STATUS_MODIFIED;
|
2006-01-28 13:09:08 +03:00
|
|
|
}
|
2006-01-28 11:03:38 +03:00
|
|
|
|
2005-11-30 08:06:10 +03:00
|
|
|
/* diff against the proper unmerged stage */
|
2006-01-28 11:03:38 +03:00
|
|
|
if (stage == diff_unmerged_stage)
|
2005-11-30 08:06:10 +03:00
|
|
|
ce = nce;
|
2005-04-17 08:29:45 +04:00
|
|
|
i++;
|
2005-11-30 08:06:10 +03:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Compensate for loop update
|
|
|
|
*/
|
|
|
|
i--;
|
2006-01-28 11:03:38 +03:00
|
|
|
|
2006-01-28 13:09:08 +03:00
|
|
|
if (combine_merges && num_compare_stages == 2) {
|
2006-01-28 11:03:38 +03:00
|
|
|
show_combined_diff(&combine.p, 2,
|
|
|
|
dense_combined_merges,
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
&rev);
|
2006-01-28 13:09:08 +03:00
|
|
|
free(combine.p.path);
|
2006-01-28 11:03:38 +03:00
|
|
|
continue;
|
|
|
|
}
|
2006-01-28 13:09:08 +03:00
|
|
|
free(combine.p.path);
|
2006-01-28 11:03:38 +03:00
|
|
|
|
2005-11-30 08:06:10 +03:00
|
|
|
/*
|
|
|
|
* Show the diff for the 'ce' if we found the one
|
|
|
|
* from the desired stage.
|
|
|
|
*/
|
2006-01-28 11:03:38 +03:00
|
|
|
show_unmerge(ce->name);
|
2005-11-30 08:06:10 +03:00
|
|
|
if (ce_stage(ce) != diff_unmerged_stage)
|
|
|
|
continue;
|
2005-04-17 08:29:45 +04:00
|
|
|
}
|
2005-05-20 06:00:36 +04:00
|
|
|
|
2005-05-06 17:45:01 +04:00
|
|
|
if (lstat(ce->name, &st) < 0) {
|
2005-05-20 20:48:38 +04:00
|
|
|
if (errno != ENOENT && errno != ENOTDIR) {
|
2005-04-27 04:17:36 +04:00
|
|
|
perror(ce->name);
|
2005-04-16 02:08:09 +04:00
|
|
|
continue;
|
2005-05-20 06:00:36 +04:00
|
|
|
}
|
2005-04-28 02:22:02 +04:00
|
|
|
if (silent)
|
2005-04-27 04:17:36 +04:00
|
|
|
continue;
|
2005-04-27 20:21:00 +04:00
|
|
|
show_file('-', ce);
|
2005-04-08 02:13:13 +04:00
|
|
|
continue;
|
|
|
|
}
|
2006-02-09 08:15:24 +03:00
|
|
|
changed = ce_match_stat(ce, &st, 0);
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
if (!changed && !rev.diffopt.find_copies_harder)
|
2005-04-08 02:13:13 +04:00
|
|
|
continue;
|
2005-04-27 04:17:36 +04:00
|
|
|
oldmode = ntohl(ce->ce_mode);
|
2005-10-12 05:45:33 +04:00
|
|
|
|
2006-03-30 10:55:43 +04:00
|
|
|
newmode = canon_mode(st.st_mode);
|
2005-10-12 05:45:33 +04:00
|
|
|
if (!trust_executable_bit &&
|
|
|
|
S_ISREG(newmode) && S_ISREG(oldmode) &&
|
|
|
|
((newmode ^ oldmode) == 0111))
|
|
|
|
newmode = oldmode;
|
|
|
|
show_modified(oldmode, newmode,
|
2005-06-20 00:14:05 +04:00
|
|
|
ce->sha1, (changed ? null_sha1 : ce->sha1),
|
2005-04-27 20:21:00 +04:00
|
|
|
ce->name);
|
2005-04-08 02:13:13 +04:00
|
|
|
}
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 22:59:32 +04:00
|
|
|
diffcore_std(&rev.diffopt);
|
|
|
|
diff_flush(&rev.diffopt);
|
2005-04-08 02:13:13 +04:00
|
|
|
return 0;
|
|
|
|
}
|