Skip to contentSkip to conversation

Builtin git-diff-files, git-diff-index, git-diff-stages, and git-diff-tree.

PATCH New Peter Eriksen 1 participant 1 message Jun 15, 2016 1 message not in the archive Kbuild

lore
Share & tools
lore
#1 lore raw

PATCH 8/8 Builtin git-diff-files, git-diff-index, git-diff-stages, and git-diff-tree.

In reply to a message not in the archive

From: Peter Eriksen <[email protected]>

---

e2d2468b8550f2760b46a2eb461b051abfef4dff

 Makefile              |   12 ++--
 builtin-diff-files.c  |   55 ++++++++++++++++++
 builtin-diff-index.c  |   39 +++++++++++++
 builtin-diff-stages.c |  105 +++++++++++++++++++++++++++++++++++
 builtin-diff-tree.c   |  148 +++++++++++++++++++++++++++++++++++++++++++++++++
 builtin.h             |    5 ++
 diff-files.c          |   54 ------------------
 diff-index.c          |   38 -------------
 diff-stages.c         |  104 ----------------------------------
 diff-tree.c           |  147 -------------------------------------------------
 git.c                 |    6 ++
 11 files changed, 363 insertions(+), 350 deletions(-)
 create mode 100644 builtin-diff-files.c
 create mode 100644 builtin-diff-index.c
 create mode 100644 builtin-diff-stages.c
 create mode 100644 builtin-diff-tree.c
 delete mode 100644 diff-files.c
 delete mode 100644 diff-index.c
 delete mode 100644 diff-stages.c
 delete mode 100644 diff-tree.c

e2d2468b8550f2760b46a2eb461b051abfef4dff

Makefile +6 -6
index b438a90..9dc1326 100644
@@ -151,9 +151,7 @@ # ... and all the rest that could be mov
 PROGRAMS = \
 	git-cat-file$X \
 	git-checkout-index$X git-clone-pack$X \
-	git-convert-objects$X git-diff-files$X \
-	git-diff-index$X git-diff-stages$X \
-	git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
+	git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
 	git-hash-object$X git-index-pack$X git-local-fetch$X \
 	git-mailinfo$X git-merge-base$X \
 	git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
@@ -173,7 +171,8 @@ BUILT_INS = git-log$X git-whatchanged$X 
 	git-grep$X git-rev-list$X git-check-ref-format$X \
 	git-init-db$X git-ls-files$X git-ls-tree$X \
 	git-tar-tree$X git-read-tree$X git-commit-tree$X \
-	git-apply$X git-show-branch$X
+	git-apply$X git-show-branch$X git-diff-files$X \
+	git-diff-index$X git-diff-stages$X git-diff-tree$X
 
 # what 'all' will build and 'install' will install, in gitexecdir
 ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
@@ -223,8 +222,9 @@ BUILTIN_OBJS = \
 	builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
 	builtin-grep.o builtin-rev-list.o builtin-check-ref-format.o \
 	builtin-init-db.o builtin-ls-files.o builtin-ls-tree.o \
-        builtin-tar-tree.o builtin-read-tree.o builtin-commit-tree.o \
-	builtin-apply.o builtin-show-branch.o
+	builtin-tar-tree.o builtin-read-tree.o builtin-commit-tree.o \
+	builtin-apply.o builtin-show-branch.o builtin-diff-files.o \
+	builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o
 
 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 LIBS = $(GITLIBS) -lz
builtin-diff-files.c new file +55 -0

55 lines not on this page · raw message

builtin-diff-index.c new file +39 -0
new file mode 100644
index 0000000..1958580
@@ -0,0 +1,39 @@
+#include "cache.h"
+#include "diff.h"
+#include "commit.h"
+#include "revision.h"
+#include "builtin.h"
+
+static const char diff_cache_usage[] =
+"git-diff-index [-m] [--cached] "
+"[<common diff options>] <tree-ish> [<path>...]"
+COMMON_DIFF_OPTIONS_HELP;
+
+int cmd_diff_index(int argc, const char **argv, char **envp)
+{
+	struct rev_info rev;
+	int cached = 0;
+	int i;
+
+	git_config(git_diff_config);
+	init_revisions(&rev);
+	rev.abbrev = 0;
+
+	argc = setup_revisions(argc, argv, &rev, NULL);
+	for (i = 1; i < argc; i++) {
+		const char *arg = argv[i];
+			
+		if (!strcmp(arg, "--cached"))
+			cached = 1;
+		else
+			usage(diff_cache_usage);
+	}
+	/*
+	 * Make sure there is one revision (i.e. pending object),
+	 * and there is no revision filtering parameters.
+	 */
+	if (!rev.pending_objects || rev.pending_objects->next ||
+	    rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
+		usage(diff_cache_usage);
+	return run_diff_index(&rev, cached);
+}
builtin-diff-stages.c new file +105 -0

105 lines not on this page · raw message

builtin-diff-tree.c new file +148 -0

148 lines not on this page · raw message

builtin.h +5 -0
index 01882ec..7620984 100644
@@ -34,5 +34,10 @@ extern int cmd_read_tree(int argc, const
 extern int cmd_commit_tree(int argc, const char **argv, char **envp);
 extern int cmd_apply(int argc, const char **argv, char **envp);
 extern int cmd_show_branch(int argc, const char **argv, char **envp);
+extern int cmd_diff_files(int argc, const char **argv, char **envp);
+extern int cmd_diff_index(int argc, const char **argv, char **envp);
+extern int cmd_diff_stages(int argc, const char **argv, char **envp);
+extern int cmd_diff_tree(int argc, const char **argv, char **envp);
+
 
 #endif
diff-files.c deleted +0 -54

54 lines not on this page · raw message

diff-index.c deleted +0 -38
deleted file mode 100644
index 8c9f601..0000000
@@ -1,38 +0,0 @@
-#include "cache.h"
-#include "diff.h"
-#include "commit.h"
-#include "revision.h"
-
-static const char diff_cache_usage[] =
-"git-diff-index [-m] [--cached] "
-"[<common diff options>] <tree-ish> [<path>...]"
-COMMON_DIFF_OPTIONS_HELP;
-
-int main(int argc, const char **argv)
-{
-	struct rev_info rev;
-	int cached = 0;
-	int i;
-
-	git_config(git_diff_config);
-	init_revisions(&rev);
-	rev.abbrev = 0;
-
-	argc = setup_revisions(argc, argv, &rev, NULL);
-	for (i = 1; i < argc; i++) {
-		const char *arg = argv[i];
-			
-		if (!strcmp(arg, "--cached"))
-			cached = 1;
-		else
-			usage(diff_cache_usage);
-	}
-	/*
-	 * Make sure there is one revision (i.e. pending object),
-	 * and there is no revision filtering parameters.
-	 */
-	if (!rev.pending_objects || rev.pending_objects->next ||
-	    rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
-		usage(diff_cache_usage);
-	return run_diff_index(&rev, cached);
-}
diff-stages.c deleted +0 -104

104 lines not on this page · raw message

diff-tree.c deleted +0 -147

147 lines not on this page · raw message

git.c +5 -1
index d29505c..8749748 100644
@@ -59,7 +59,11 @@ static void handle_internal_command(int 
 		{ "read-tree", cmd_read_tree },
 		{ "commit-tree", cmd_commit_tree },
 		{ "apply", cmd_apply },
-		{ "show-branch", cmd_show_branch }
+		{ "show-branch", cmd_show_branch },
+		{ "diff-files", cmd_diff_files },
+		{ "diff-index", cmd_diff_index },
+		{ "diff-stages", cmd_diff_stages },
+		{ "diff-tree", cmd_diff_tree }
 	};
 	int i;
 
Signature · 1 line
1.3.3.g288c