threads / patch / 1198

patch, 4 partsadd write-tree --missing OK, fix cogito -N options

Subject: [PATCH 0/4] add write-tree --missing OK, fix cogito -N options

## tl;dr

5 messages between Jul 11, 2005 and Jul 11, 2005. Diffs are folded; open one to read it.

replies: 4people: 1as markdown or json

Bryan Larsen· Jul 11, 2005, 03:53 UTC · lore

All of my patches have been applied to git and cogito except for the first one, the patch that adds the --no-check option to git-write-tree. This is problematic because one of the patches that Petr applied to cogito requires git-write-tree --no-check.

As well, there are two bugs in cg-init: the one that Joel Becker found, plus the -N option needs to be passed to cg-commit.

Finally, Junio suggested that the --no-check option be renamed to --missing-ok.

These patches fix the situation up.

1/4: bugfix for cg-init ARGV 2/4: bugfix for cg-init. 3/4: add --missing-ok option to git-write-tree. 4/4: change cg-commit to use --missing-ok instead of --no-check.

Bryan Larsen· Jul 11, 2005, 03:53 UTC · re: Bryan Larsen · lore

[PATCH 1/4] bugfix for cg-init: ARGV

Bugfix: nasty typo (ARGV instead of ARGS) in my last patch to cg-init.

Signed off by: Bryan Larsen <bryan.larsen@gmail.com> ---

Show changes to cg-init +1 −1
diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -33,7 +33,7 @@ while optparse; do
 	fi
 done
 
-uri=$ARGV
+uri=$ARGS
 
 [ -e $_git ] && die "$_git already exists"
 
Bryan Larsen· Jul 11, 2005, 03:53 UTC · re: Bryan Larsen · lore

[PATCH 2/4] bugfix for cg-init -N: pass -N to cg-commit

Bugfix for cg-init -N:  the -N option needs to be passed down into cg-commit as well.
Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
Show changes to cg-init +1 −1
diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -56,7 +56,7 @@ if [ "$uri" ]; then
 else
 	git-read-tree # Seed the dircache
 	find * \( -type f -o -type l \) -print0 | xargs -0r cg-add ${infoonly}
-	cg-commit -C -m"Initial commit" -E
+	cg-commit -C -m"Initial commit" -E ${infoonly}
 fi
 
 trap "" SIGTERM EXIT
Bryan Larsen· Jul 11, 2005, 03:53 UTC · re: Bryan Larsen · lore

[PATCH 3/4] add --missing-ok option to write-tree

Add --missing-ok option to git-write.tree.  This option allows a write-tree even if the referenced objects are not in the database.
Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
Show changes to 2 files +19 −2

Documentation/git-write-tree.txt, write-tree.c

diff --git a/Documentation/git-write-tree.txt b/Documentation/git-write-tree.txt
--- a/Documentation/git-write-tree.txt
+++ b/Documentation/git-write-tree.txt
@@ -10,6 +10,7 @@ git-write-tree - Creates a tree from the
 SYNOPSIS
 --------
 'git-write-tree'
+		[--missing-ok]
 
 DESCRIPTION
 -----------
@@ -23,7 +24,11 @@ In order to have that match what is actu
 now, you need to have done a "git-update-cache" phase before you did the
 "git-write-tree".
 
-
+OPTIONS
+-------
+--missing-ok::
+	Normally "git-write-tree" ensures that the objects referenced by the
+	directory exist in the object database.  This option disables this check.
 
 
 ////////////////////////////////////////////////////////////////
diff --git a/write-tree.c b/write-tree.c
--- a/write-tree.c
+++ b/write-tree.c
@@ -5,6 +5,8 @@
  */
 #include "cache.h"
 
+static int missing_ok = 0;
+
 static int check_valid_sha1(unsigned char *sha1)
 {
 	int ret;
@@ -61,7 +63,7 @@ static int write_tree(struct cache_entry
 			sha1 = subdir_sha1;
 		}
 
-		if (check_valid_sha1(sha1) < 0)
+		if (!missing_ok && check_valid_sha1(sha1) < 0)
 			exit(1);
 
 		entrylen = pathlen - baselen;
@@ -86,6 +88,16 @@ int main(int argc, char **argv)
 	int i, funny;
 	int entries = read_cache();
 	unsigned char sha1[20];
+	
+	if (argc==2) {
+		if (!strcmp(argv[1], "--missing-ok"))
+			missing_ok = 1;
+		else
+			die("unknown option %s", argv[1]);
+	}
+	
+	if (argc>2)
+		die("too many options");
 
 	if (entries < 0)
 		die("git-write-tree: error reading cache");
Bryan Larsen· Jul 11, 2005, 03:53 UTC · re: Bryan Larsen · lore

[PATCH 4/4] switch cg-commit -N to use --missing-ok instead of --no-check

Make cg-commit aware of the rename of git-write-tree --no-check to --missing-ok.
Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
Show changes to cg-commit +3 −3
diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -111,13 +111,13 @@ forceeditor=
 ignorecache=
 infoonly=
 commitalways=
-nocheck=
+missingok=
 msgs=()
 while optparse; do
 	if optparse -C; then
 		ignorecache=1
 	elif optparse -N; then
-		nocheck=--no-check
+		missingok=--missing-ok
 		infoonly=--info-only
 	elif optparse -e; then
 		forceeditor=1
@@ -311,7 +311,7 @@ if [ -s "$_git/HEAD" ]; then
 	oldheadstr="-p $oldhead"
 fi
 
-treeid=$(git-write-tree ${nocheck})
+treeid=$(git-write-tree ${missingok})
 [ "$treeid" ] || die "git-write-tree failed"
 if [ ! "$force" ] && [ ! "$merging" ] && [ "$oldhead" ] &&
    [ "$treeid" = "$(tree-id)" ]; then

← back to recent threads