#include "revision.h"
#include "log-tree.h"
#include "builtin.h"
+#include "submodule.h"
struct blobinfo {
unsigned char sha1[20];
};
static const char builtin_diff_usage[] =
-"git diff <options> <rev>{0,2} -- <path>*";
+"git diff [<options>] [<commit> [<commit>]] [--] [<path>...]";
static void stuff_change(struct diff_options *opt,
unsigned old_mode, unsigned new_mode,
*/
prefix = setup_git_directory_gently(&nongit);
+ gitmodules_config();
git_config(git_diff_ui_config, NULL);
if (diff_use_color_default == -1)
else if (!strcmp(arg, "--cached") ||
!strcmp(arg, "--staged")) {
add_head_to_pending(&rev);
- if (!rev.pending.nr)
- die("No HEAD commit to compare with (yet)");
+ if (!rev.pending.nr) {
+ struct tree *tree;
+ tree = lookup_tree((const unsigned char*)EMPTY_TREE_SHA1_BIN);
+ add_pending_object(&rev, &tree->object, "HEAD");
+ }
break;
}
}
else if (ents == 2)
result = builtin_diff_tree(&rev, argc, argv, ent);
else if (ent[0].item->flags & UNINTERESTING) {
- /*
- * Perhaps the user gave us A...B, which expands
- * to a list of negative merge bases followed by
- * A (symmetric-left) and B? Let's make sure...
- */
- for (i = 1; i < ents; i++)
- if (!(ent[i].item->flags & UNINTERESTING))
- break;
- if (ents != i + 2 ||
- (ent[i+1].item->flags & UNINTERESTING) ||
- (!(ent[i].item->flags & SYMMETRIC_LEFT)) ||
- (ent[i+1].item->flags & SYMMETRIC_LEFT))
- die("what do you mean by that?");
/*
* diff A...B where there is at least one merge base
* between A and B. We have ent[0] == merge-base,