* [PATCH 1/8] git-apply: work from subdirectory.
From: Junio C Hamano @ 2005-11-26 9:56 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzjtn3h1.fsf@assigned-by-dhcp.cox.net>
This adds three things:
- prefix_filename() is like prefix_path() but can be used to
name any file on the filesystem, not the files that might go
into the index file.
- git-apply uses setup_git_directory() to find out the GIT_DIR
and reads configuration file. Later this would allow us to
affect the behaviour of the command from the configuration.
- When git-apply is run from a subdirectory, it applies the
given patch only to the files under the current directory and
below.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
apply.c | 15 +++++++++++++++
cache.h | 1 +
setup.c | 15 +++++++++++++++
3 files changed, 31 insertions(+), 0 deletions(-)
applies-to: 9ccf8849fa9b522a344645c2f28f12ab036e30d5
c20b8d006edfa964b3df5e4c5cc28cb93edcb240
diff --git a/apply.c b/apply.c
index 50be8f3..ae06d41 100644
--- a/apply.c
+++ b/apply.c
@@ -16,6 +16,9 @@
// --numstat does numeric diffstat, and doesn't actually apply
// --index-info shows the old and new index info for paths if available.
//
+static const char *prefix;
+static int prefix_length;
+
static int allow_binary_replacement = 0;
static int check_index = 0;
static int write_index = 0;
@@ -1706,6 +1709,12 @@ static int use_patch(struct patch *p)
return 0;
x = x->next;
}
+ if (prefix && *prefix) {
+ int pathlen = strlen(pathname);
+ if (pathlen <= prefix_length ||
+ memcmp(prefix, pathname, prefix_length))
+ return 0;
+ }
return 1;
}
@@ -1784,6 +1793,10 @@ int main(int argc, char **argv)
int i;
int read_stdin = 1;
+ prefix = setup_git_directory();
+ prefix_length = prefix ? strlen(prefix) : 0;
+ git_config(git_default_config);
+
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
int fd;
@@ -1845,6 +1858,8 @@ int main(int argc, char **argv)
line_termination = 0;
continue;
}
+ arg = prefix_filename(prefix, prefix_length, arg);
+
fd = open(arg, O_RDONLY);
if (fd < 0)
usage(apply_usage);
diff --git a/cache.h b/cache.h
index 6ac94c5..62920ce 100644
--- a/cache.h
+++ b/cache.h
@@ -149,6 +149,7 @@ extern char *get_graft_file(void);
extern const char **get_pathspec(const char *prefix, const char **pathspec);
extern const char *setup_git_directory(void);
extern const char *prefix_path(const char *prefix, int len, const char *path);
+extern const char *prefix_filename(const char *prefix, int len, const char *path);
#define alloc_nr(x) (((x)+16)*3/2)
diff --git a/setup.c b/setup.c
index ab3c778..54f6a34 100644
--- a/setup.c
+++ b/setup.c
@@ -47,6 +47,21 @@ const char *prefix_path(const char *pref
return path;
}
+/*
+ * Unlike prefix_path, this should be used if the named file does
+ * not have to interact with index entry; i.e. name of a random file
+ * on the filesystem.
+ */
+const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
+{
+ static char path[PATH_MAX];
+ if (!pfx || !*pfx || arg[0] == '/')
+ return arg;
+ memcpy(path, pfx, pfx_len);
+ strcpy(path + pfx_len, arg);
+ return path;
+}
+
const char **get_pathspec(const char *prefix, const char **pathspec)
{
const char *entry = *pathspec;
---
0.99.9.GIT
^ permalink raw reply related
* [PATCH 2/8] peek-remote: honor proxy config even from subdirectory.
From: Junio C Hamano @ 2005-11-26 9:56 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzjtn3h1.fsf@assigned-by-dhcp.cox.net>
Introduce setup_git_directory_gently() which does not die() if
called outside a git repository, and use it so that later
git_config() would work as expected even from a subdirectory,
without failing the whole command if run outside a git
repository.
Use it at the beginning of peek-remote so that git:// proxy can
be picked up from the configuration file.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
cache.h | 1 +
peek-remote.c | 3 +++
setup.c | 11 ++++++++---
3 files changed, 12 insertions(+), 3 deletions(-)
applies-to: 6afe0a2dc5da18d1090e8d660e45e2c777bfeaaa
1fe3fae4e1dcd864af4010ee572a3bc6de996e95
diff --git a/cache.h b/cache.h
index 62920ce..13806d3 100644
--- a/cache.h
+++ b/cache.h
@@ -147,6 +147,7 @@ extern char *get_graft_file(void);
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
extern const char **get_pathspec(const char *prefix, const char **pathspec);
+extern const char *setup_git_directory_gently(int *);
extern const char *setup_git_directory(void);
extern const char *prefix_path(const char *prefix, int len, const char *path);
extern const char *prefix_filename(const char *prefix, int len, const char *path);
diff --git a/peek-remote.c b/peek-remote.c
index ee49bf3..a90cf22 100644
--- a/peek-remote.c
+++ b/peek-remote.c
@@ -27,6 +27,9 @@ int main(int argc, char **argv)
char *dest = NULL;
int fd[2];
pid_t pid;
+ int nongit = 0;
+
+ setup_git_directory_gently(&nongit);
for (i = 1; i < argc; i++) {
char *arg = argv[i];
diff --git a/setup.c b/setup.c
index 54f6a34..b697bf9 100644
--- a/setup.c
+++ b/setup.c
@@ -107,7 +107,7 @@ static int is_toplevel_directory(void)
return 1;
}
-static const char *setup_git_directory_1(void)
+const char *setup_git_directory_gently(int *nongit_ok)
{
static char cwd[PATH_MAX+1];
int len, offset;
@@ -154,8 +154,13 @@ static const char *setup_git_directory_1
break;
chdir("..");
do {
- if (!offset)
+ if (!offset) {
+ if (nongit_ok) {
+ *nongit_ok = 1;
+ return NULL;
+ }
die("Not a git repository");
+ }
} while (cwd[--offset] != '/');
}
@@ -171,6 +176,6 @@ static const char *setup_git_directory_1
const char *setup_git_directory(void)
{
- const char *retval = setup_git_directory_1();
+ const char *retval = setup_git_directory_gently(NULL);
return retval;
}
---
0.99.9.GIT
^ permalink raw reply related
* [PATCH 3/8] fsck-objects: work from subdirectory.
From: Junio C Hamano @ 2005-11-26 9:56 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzjtn3h1.fsf@assigned-by-dhcp.cox.net>
Not much point making it work from subdirectory, but for a
consistency make it so.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
fsck-objects.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
applies-to: 802056c105a0cb936137f141a8e6e546224f3a07
1bd646921ec7278fad9a38281678227769046291
diff --git a/fsck-objects.c b/fsck-objects.c
index 0433a1d..90e638e 100644
--- a/fsck-objects.c
+++ b/fsck-objects.c
@@ -431,6 +431,8 @@ int main(int argc, char **argv)
{
int i, heads;
+ setup_git_directory();
+
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
---
0.99.9.GIT
^ permalink raw reply related
* [PATCH 4/8] checkout-index: work from subdirectory.
From: Junio C Hamano @ 2005-11-26 9:56 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzjtn3h1.fsf@assigned-by-dhcp.cox.net>
With this, git-checkout-index from a subdirectory works as
expected. Note that "git-checkout-index -a" checks out files
only in the current directory and under.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
checkout-index.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
applies-to: 5609c84ffd98e1b253c4cb46523245c3be553624
556dc2ebd6566fc032444224a145d3cb422eecc4
diff --git a/checkout-index.c b/checkout-index.c
index dab3778..f1e716d 100644
--- a/checkout-index.c
+++ b/checkout-index.c
@@ -34,6 +34,9 @@
*/
#include "cache.h"
+static const char *prefix;
+static int prefix_length;
+
static struct checkout state = {
.base_dir = "",
.base_dir_len = 0,
@@ -69,6 +72,10 @@ static int checkout_all(void)
struct cache_entry *ce = active_cache[i];
if (ce_stage(ce))
continue;
+ if (prefix && *prefix &&
+ ( ce_namelen(ce) <= prefix_length ||
+ memcmp(prefix, ce->name, prefix_length) ))
+ continue;
if (checkout_entry(ce, &state) < 0)
errs++;
}
@@ -91,6 +98,9 @@ int main(int argc, char **argv)
int newfd = -1;
int all = 0;
+ prefix = setup_git_directory();
+ prefix_length = prefix ? strlen(prefix) : 0;
+
if (read_cache() < 0) {
die("invalid cache");
}
@@ -155,7 +165,7 @@ int main(int argc, char **argv)
if (all)
die("git-checkout-index: don't mix '--all' and explicit filenames");
- checkout_file(arg);
+ checkout_file(prefix_path(prefix, prefix_length, arg));
}
if (all)
---
0.99.9.GIT
^ permalink raw reply related
* [PATCH 5/8] hash-object: work within subdirectory.
From: Junio C Hamano @ 2005-11-26 9:57 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzjtn3h1.fsf@assigned-by-dhcp.cox.net>
When -w is given, it needs to find out where the .git directory
is, so run the setup_git_directory() when we see a -w.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
hash-object.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
applies-to: b0041c758e0fc01e5ec05bd0543d04d1a9cb17f5
61fdef6a50c99c98feebd71f499450cf97a8c169
diff --git a/hash-object.c b/hash-object.c
index c8c9adb..3075328 100644
--- a/hash-object.c
+++ b/hash-object.c
@@ -6,6 +6,9 @@
*/
#include "cache.h"
+static const char *prefix;
+static int prefix_length = -1;
+
static void hash_object(const char *path, const char *type, int write_object)
{
int fd;
@@ -36,10 +39,20 @@ int main(int argc, char **argv)
die(hash_object_usage);
type = argv[i];
}
- else if (!strcmp(argv[i], "-w"))
+ else if (!strcmp(argv[i], "-w")) {
+ if (prefix_length < 0) {
+ prefix = setup_git_directory();
+ prefix_length = prefix ? strlen(prefix) : 0;
+ }
write_object = 1;
- else
- hash_object(argv[i], type, write_object);
+ }
+ else {
+ char *arg = argv[i];
+ if (0 <= prefix_length)
+ arg = prefix_filename(prefix, prefix_length,
+ arg);
+ hash_object(arg, type, write_object);
+ }
}
return 0;
}
---
0.99.9.GIT
^ permalink raw reply related
* [PATCH 6/8] ls-tree: work from subdirectory.
From: Junio C Hamano @ 2005-11-26 9:57 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzjtn3h1.fsf@assigned-by-dhcp.cox.net>
This makes ls-tree to work from subdirectory. It defaults to
show the paths under the current subdirectory, and interprets
user-supplied paths as relative to the current subdirectory.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
ls-tree.c | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
applies-to: 4e55e4796ee699c9361b3751a36a85ba282119a8
40af60bb52cd86e1f089eeb89b2d3d79531c55d1
diff --git a/ls-tree.c b/ls-tree.c
index d9f15e3..ed546a5 100644
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -8,6 +8,8 @@
#include "tree.h"
#include "quote.h"
+static const char *prefix;
+
static int line_termination = '\n';
#define LS_RECURSIVE 1
#define LS_TREE_ONLY 2
@@ -204,7 +206,7 @@ static int list_one(const char *path)
return err;
}
-static int list(char **path)
+static int list(const char **path)
{
int i;
int err = 0;
@@ -216,11 +218,16 @@ static int list(char **path)
static const char ls_tree_usage[] =
"git-ls-tree [-d] [-r] [-z] <tree-ish> [path...]";
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
{
- static char *path0[] = { "", NULL };
- char **path;
+ static const char *path0[] = { "", NULL };
+ const char **path;
unsigned char sha1[20];
+ int nongit = 0;
+
+ prefix = setup_git_directory_gently(&nongit);
+ if (prefix)
+ path0[0] = prefix;
while (1 < argc && argv[1][0] == '-') {
switch (argv[1][1]) {
@@ -244,7 +251,11 @@ int main(int argc, char **argv)
if (get_sha1(argv[1], sha1) < 0)
usage(ls_tree_usage);
- path = (argc == 2) ? path0 : (argv + 2);
+ if (argc == 2)
+ path = path0;
+ else
+ path = get_pathspec(prefix, argv + 2);
+
prepare_root(sha1);
if (list(path) < 0)
die("list failed");
---
0.99.9.GIT
^ permalink raw reply related
* [PATCH 7/8] Make networking commands to work from a subdirectory.
From: Junio C Hamano @ 2005-11-26 9:57 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzjtn3h1.fsf@assigned-by-dhcp.cox.net>
These are whole-tree operations and there is not much point
making them operable from within a subdirectory, but it is easy
to do so, and using setup_git_directory() upfront helps git://
proxy specification picked up from the correct place.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
clone-pack.c | 2 ++
fetch-pack.c | 2 ++
http-fetch.c | 2 ++
http-push.c | 1 +
local-fetch.c | 2 ++
send-pack.c | 1 +
ssh-fetch.c | 2 ++
ssh-upload.c | 3 +++
8 files changed, 15 insertions(+), 0 deletions(-)
applies-to: 40288d9fe5f400d387e29cd7ec2fa4f1ee4eecca
e01beacec2b24cf1ca59bd8a0fdbe301119ab061
diff --git a/clone-pack.c b/clone-pack.c
index 9609219..a99a95c 100644
--- a/clone-pack.c
+++ b/clone-pack.c
@@ -271,6 +271,8 @@ int main(int argc, char **argv)
int fd[2];
pid_t pid;
+ setup_git_directory();
+
nr_heads = 0;
heads = NULL;
for (i = 1; i < argc; i++) {
diff --git a/fetch-pack.c b/fetch-pack.c
index 6565982..58ba209 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -424,6 +424,8 @@ int main(int argc, char **argv)
int fd[2];
pid_t pid;
+ setup_git_directory();
+
nr_heads = 0;
heads = NULL;
for (i = 1; i < argc; i++) {
diff --git a/http-fetch.c b/http-fetch.c
index 4353173..ad59f1c 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -922,6 +922,8 @@ int main(int argc, char **argv)
int arg = 1;
int rc = 0;
+ setup_git_directory();
+
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
get_tree = 1;
diff --git a/http-push.c b/http-push.c
index 76c7886..250a9b9 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1239,6 +1239,7 @@ int main(int argc, char **argv)
int rc = 0;
int i;
+ setup_git_directory();
setup_ident();
remote = xmalloc(sizeof(*remote));
diff --git a/local-fetch.c b/local-fetch.c
index 0931109..fa9e697 100644
--- a/local-fetch.c
+++ b/local-fetch.c
@@ -207,6 +207,8 @@ int main(int argc, char **argv)
char *commit_id;
int arg = 1;
+ setup_git_directory();
+
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't')
get_tree = 1;
diff --git a/send-pack.c b/send-pack.c
index 3eeb18f..2a14b00 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -273,6 +273,7 @@ int main(int argc, char **argv)
int fd[2], ret;
pid_t pid;
+ setup_git_directory();
argv++;
for (i = 1; i < argc; i++, argv++) {
char *arg = *argv;
diff --git a/ssh-fetch.c b/ssh-fetch.c
index bf01fbc..4eb9e04 100644
--- a/ssh-fetch.c
+++ b/ssh-fetch.c
@@ -131,6 +131,8 @@ int main(int argc, char **argv)
prog = getenv("GIT_SSH_PUSH");
if (!prog) prog = "git-ssh-upload";
+ setup_git_directory();
+
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
get_tree = 1;
diff --git a/ssh-upload.c b/ssh-upload.c
index 603abcc..b675a0b 100644
--- a/ssh-upload.c
+++ b/ssh-upload.c
@@ -121,6 +121,9 @@ int main(int argc, char **argv)
prog = getenv(COUNTERPART_ENV_NAME);
if (!prog) prog = COUNTERPART_PROGRAM_NAME;
+
+ setup_git_directory();
+
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 'w')
arg++;
---
0.99.9.GIT
^ permalink raw reply related
* [PATCH 8/8] Make the rest of commands work from a subdirectory.
From: Junio C Hamano @ 2005-11-26 9:57 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzjtn3h1.fsf@assigned-by-dhcp.cox.net>
These commands are converted to run from a subdirectory.
commit-tree convert-objects merge-base merge-index mktag
pack-objects pack-redundant prune-packed read-tree tar-tree
unpack-file unpack-objects update-server-info write-tree
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
commit-tree.c | 2 ++
convert-objects.c | 2 ++
merge-base.c | 2 ++
merge-index.c | 1 +
mktag.c | 2 ++
pack-objects.c | 2 ++
pack-redundant.c | 2 ++
prune-packed.c | 2 ++
read-tree.c | 2 ++
tar-tree.c | 2 ++
unpack-file.c | 2 ++
unpack-objects.c | 2 ++
update-server-info.c | 2 ++
write-tree.c | 5 ++++-
14 files changed, 29 insertions(+), 1 deletions(-)
applies-to: 46e976598ab7b7822d7664fdcc88dc63d2e9cf7a
87a21588fb4f8ed433364716ccb90ef934a99585
diff --git a/commit-tree.c b/commit-tree.c
index b60299f..4634b50 100644
--- a/commit-tree.c
+++ b/commit-tree.c
@@ -91,6 +91,8 @@ int main(int argc, char **argv)
if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
usage(commit_tree_usage);
+ setup_git_directory();
+
check_valid(tree_sha1, "tree");
for (i = 2; i < argc; i += 2) {
char *a, *b;
diff --git a/convert-objects.c b/convert-objects.c
index a892013..d78a8b4 100644
--- a/convert-objects.c
+++ b/convert-objects.c
@@ -316,6 +316,8 @@ int main(int argc, char **argv)
unsigned char sha1[20];
struct entry *entry;
+ setup_git_directory();
+
if (argc != 2 || get_sha1(argv[1], sha1))
usage("git-convert-objects <sha1>");
diff --git a/merge-base.c b/merge-base.c
index 751c3c2..e73fca7 100644
--- a/merge-base.c
+++ b/merge-base.c
@@ -236,6 +236,8 @@ int main(int argc, char **argv)
struct commit *rev1, *rev2;
unsigned char rev1key[20], rev2key[20];
+ setup_git_directory();
+
while (1 < argc && argv[1][0] == '-') {
char *arg = argv[1];
if (!strcmp(arg, "-a") || !strcmp(arg, "--all"))
diff --git a/merge-index.c b/merge-index.c
index 727527f..024196e 100644
--- a/merge-index.c
+++ b/merge-index.c
@@ -102,6 +102,7 @@ int main(int argc, char **argv)
if (argc < 3)
usage("git-merge-index [-o] [-q] <merge-program> (-a | <filename>*)");
+ setup_git_directory();
read_cache();
i = 1;
diff --git a/mktag.c b/mktag.c
index 585677e..97e270a 100644
--- a/mktag.c
+++ b/mktag.c
@@ -111,6 +111,8 @@ int main(int argc, char **argv)
if (argc != 1)
usage("cat <signaturefile> | git-mktag");
+ setup_git_directory();
+
// Read the signature
size = 0;
for (;;) {
diff --git a/pack-objects.c b/pack-objects.c
index 8864a31..a62c9f8 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -473,6 +473,8 @@ int main(int argc, char **argv)
struct object_entry **list;
int i;
+ setup_git_directory();
+
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
diff --git a/pack-redundant.c b/pack-redundant.c
index 793fa08..0a43278 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -600,6 +600,8 @@ int main(int argc, char **argv)
unsigned char *sha1;
char buf[42]; /* 40 byte sha1 + \n + \0 */
+ setup_git_directory();
+
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if(!strcmp(arg, "--")) {
diff --git a/prune-packed.c b/prune-packed.c
index 26123f7..d24b097 100644
--- a/prune-packed.c
+++ b/prune-packed.c
@@ -58,6 +58,8 @@ int main(int argc, char **argv)
{
int i;
+ setup_git_directory();
+
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
diff --git a/read-tree.c b/read-tree.c
index df156ea..e3b9c0d 100644
--- a/read-tree.c
+++ b/read-tree.c
@@ -629,6 +629,8 @@ int main(int argc, char **argv)
unsigned char sha1[20];
merge_fn_t fn = NULL;
+ setup_git_directory();
+
newfd = hold_index_file_for_update(&cache_file, get_index_file());
if (newfd < 0)
die("unable to create new cachefile");
diff --git a/tar-tree.c b/tar-tree.c
index 970c4bb..bacb23a 100644
--- a/tar-tree.c
+++ b/tar-tree.c
@@ -407,6 +407,8 @@ int main(int argc, char **argv)
void *buffer;
unsigned long size;
+ setup_git_directory();
+
switch (argc) {
case 3:
basedir = argv[2];
diff --git a/unpack-file.c b/unpack-file.c
index d4ac3a5..07303f8 100644
--- a/unpack-file.c
+++ b/unpack-file.c
@@ -29,6 +29,8 @@ int main(int argc, char **argv)
if (argc != 2 || get_sha1(argv[1], sha1))
usage("git-unpack-file <sha1>");
+ setup_git_directory();
+
puts(create_temp_file(sha1));
return 0;
}
diff --git a/unpack-objects.c b/unpack-objects.c
index 8490895..cfd61ae 100644
--- a/unpack-objects.c
+++ b/unpack-objects.c
@@ -269,6 +269,8 @@ int main(int argc, char **argv)
int i;
unsigned char sha1[20];
+ setup_git_directory();
+
for (i = 1 ; i < argc; i++) {
const char *arg = argv[i];
diff --git a/update-server-info.c b/update-server-info.c
index e824f62..0b6c383 100644
--- a/update-server-info.c
+++ b/update-server-info.c
@@ -19,5 +19,7 @@ int main(int ac, char **av)
if (i != ac)
usage(update_server_info_usage);
+ setup_git_directory();
+
return !!update_server_info(force);
}
diff --git a/write-tree.c b/write-tree.c
index 2b2c6b7..0aac32f 100644
--- a/write-tree.c
+++ b/write-tree.c
@@ -86,9 +86,12 @@ static int write_tree(struct cache_entry
int main(int argc, char **argv)
{
int i, funny;
- int entries = read_cache();
+ int entries;
unsigned char sha1[20];
+ setup_git_directory();
+
+ entries = read_cache();
if (argc == 2) {
if (!strcmp(argv[1], "--missing-ok"))
missing_ok = 1;
---
0.99.9.GIT
^ permalink raw reply related
* Re: [PATCH 1/9] archimport: first, make sure it still compiles
From: Martin Langhoff @ 2005-11-26 10:51 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Eric Wong, git list, Martin Langhoff
In-Reply-To: <Pine.LNX.4.64.0511241051170.13959@g5.osdl.org>
On 11/24/05, Linus Torvalds <torvalds@osdl.org> wrote:
> I don't know about Junio, but if I were him, I'd have preferred that all
> your patches had a
>
> archimport: ..
>
> prefix in the subject line, not just the first one.
Good catch -- I'll prefix them all as I merge them. If Junio pulls
from my tree, he'll get them prefixed.
cheers,
martin
^ permalink raw reply
* Re: [PATCH 0/8] Make C-level operable from subdirectories
From: Junio C Hamano @ 2005-11-26 10:59 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Johannes Schindelin, git
In-Reply-To: <7voe477n4i.fsf_-_@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
> Linus Torvalds <torvalds@osdl.org> writes:
>
>> On Fri, 25 Nov 2005, Junio C Hamano wrote:
>>>
>>> I once advocated for an environment to name the top of working
>>> tree directory --- it might make sense to resurrect that one.
>>
>> Please don't.
>>
>> We should just make the scripts do it automatically instead.
>
> Here comes an 8-patch series.
>
> [PATCH 1/8] git-apply: work from subdirectory.
> [PATCH 2/8] peek-remote: honor proxy config even from subdirectory.
> [PATCH 3/8] fsck-objects: work from subdirectory.
> [PATCH 4/8] checkout-index: work from subdirectory.
> [PATCH 5/8] hash-object: work within subdirectory.
> [PATCH 6/8] ls-tree: work from subdirectory.
> [PATCH 7/8] Make networking commands to work from a subdirectory.
> [PATCH 8/8] Make the rest of commands work from a subdirectory.
In case it was not obvious,...
I think your GIT_DIR=`git-rev-parse --git-dir` patch would make
things work better on top of these changes, while making many of
them silently do funny things as you warned.
For example, among the ones I mentioned in my previous message:
- git-checkout with or without -b to switch branches work.
This is because "git-read-tree -u" is not constrained by the
current directory and operates on the whole working tree.
- git-checkout <ent> <path>... works as expected. It takes cwd
relative paths and updates the index and working tree for
only specified paths from the named ent.
- git-checkout -f works in a confusing way; only the files
under the current directory is updated. This is because
"git-checkout-index -a" behaves that way. git-checkout -f to
revert to the current HEAD is probably good to work this way,
but doing this while switching branches is too confusing.
- git-reset --hard also works in a funny way. It leaves paths
outside the current directory intact, because ls-tree reports
only the files in the current directory while ls-files
reports all.
- git-prune works. git-tag works as before.
It could be argued that it was a mistake that [PATCH 4/8] and
[PATCH 6/8] changed checkout-index and ls-tree to limit their
scope to the current directory, but that is consistent with what
rev-list (log and whatchanged) and diff do, and might be
debatably useful. Which suggests that things like git-checkout
and git-reset whose normal mode of operation should be
whole-tree should chdir up and do the path prefixing to convert
original cwd relative paths to repository relative.
^ permalink raw reply
* [ANNOUNCE qgit-0.97.3]
From: Marco Costalba @ 2005-11-26 12:39 UTC (permalink / raw)
To: git
qgit, a git GUI viewer.
With qgit you will be able to browse revisions history, view patch
content and changed files, graphically following different development
branches.
FEATURES
- View revisions, diffs, files history, files annotation, archive tree.
- Commit changes visually cherry picking modified files.
- Apply or format patch series from selected commits, drag and
drop commits between two instances of qgit.
- qgit implements a GUI for the most common StGIT commands like
push/pop and apply/format patches. You can also create new patches
or refresh current top one using the same semantics of git commit,
i.e. cherry picking single modified files.
NEW IN THIS RELEASE
This is mainly a fix release with only some little nice features added
(see changelog below).
Due to some good fixes and stability improvements I suggest to update.
qgit is now in '(almost) just fixes' mode to be in good shape for the
time of git 1.0 is out, then I will relase qgit 1.0
DOWNLOAD
The page with all the download links is:
http://digilander.libero.it/mcostalba/
INSTALLATION
You need scons and qt-mt developer libs, version 3.3.4 or better,
already installed.
qgit is NOT compatible with Qt4.
On some platforms (Debian) you should set QTDIR before to compile.
- unpack tar file
- make
- make install
qgit will be installed in $HOME/bin
CHANGELOG
- qgit now works from subdirectories.
- added 'save file as' feature. To save on disk selected tree files.
- added support for tag messages. When tagging a revision it is
possible to add a message, this will be shown in status bar, togheter
with tag name, when a tagged revision is selected.
- added support for tag delete.
- rewritten file/annotate viewer to be more stable when user changes
request while updating. Now should be possible to safely browse
through logs and archive tree without waiting for update to finish.
- do not assume git bins directory is in $PATH. Use 'git --exec-path'.
- fix possibly wrong description for revs with no commit messages
nor subjects
- fix annotate viewer to update correctly with 'jump to rev' function
- fix diff viewer to always center on selected file
- fix regression, bad annotation of deleted files
- various GUI tweaks and small fixes.
Marco
___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
^ permalink raw reply
* Re: [PATCH 1/8] git-apply: work from subdirectory.
From: Linus Torvalds @ 2005-11-26 17:36 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7viruf68bz.fsf@assigned-by-dhcp.cox.net>
On Sat, 26 Nov 2005, Junio C Hamano wrote:
>
> This adds three things:
>
> - prefix_filename() is like prefix_path() but can be used to
> name any file on the filesystem, not the files that might go
> into the index file.
>
> - git-apply uses setup_git_directory() to find out the GIT_DIR
> and reads configuration file. Later this would allow us to
> affect the behaviour of the command from the configuration.
>
> - When git-apply is run from a subdirectory, it applies the
> given patch only to the files under the current directory and
> below.
>
> Signed-off-by: Junio C Hamano <junkio@cox.net>
This breaks git-apply when used to just do a "diffstat", or when used on a
non-git repository.
For "git-apply --stat", we definitely don't want to force it inside a git
directory. In fact, even _trying_ to find a git directory would be wrong.
The only case where we care about a git directory is the "--index" case.
In all other cases we should happily apply it (or stat it).
Linus
^ permalink raw reply
* Re: [PATCH 6/8] ls-tree: work from subdirectory.
From: Linus Torvalds @ 2005-11-26 17:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
In-Reply-To: <7vpson4tqi.fsf@assigned-by-dhcp.cox.net>
On Sat, 26 Nov 2005, Junio C Hamano wrote:
>
> --- a/ls-tree.c
> +++ b/ls-tree.c
> @@ -8,6 +8,8 @@
> #include "tree.h"
> #include "quote.h"
>
> +static const char *prefix;
> +
No need to have this visible outside of "main()".
> + prefix = setup_git_directory_gently(&nongit);
> + if (prefix)
> + path0[0] = prefix;
...
> + if (argc == 2)
> + path = path0;
> + else
> + path = get_pathspec(prefix, argv + 2);
> +
And this is just ugly.
git-ls-tree should be rewritten to use a pathspec the same way everybody
else does. Right now it's the odd man out: if you do
git-ls-tree HEAD divers/char drivers/
it will show the same files _twice_, which is not how pathspecs in general
work.
How about this patch? It breaks some of the git-ls-tree tests, but it
makes git-ls-tree work a lot more like other git pathspec commands, and it
removes more than 150 lines by re-using the recursive tree traversal (but
the "-d" flag is gone for good, so I'm not pushing this too hard).
Linus
---
diff --git a/ls-tree.c b/ls-tree.c
index d9f15e3..598b729 100644
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -13,215 +13,32 @@ static int line_termination = '\n';
#define LS_TREE_ONLY 2
static int ls_options = 0;
-static struct tree_entry_list root_entry;
-
-static void prepare_root(unsigned char *sha1)
-{
- unsigned char rsha[20];
- unsigned long size;
- void *buf;
- struct tree *root_tree;
-
- buf = read_object_with_reference(sha1, "tree", &size, rsha);
- free(buf);
- if (!buf)
- die("Could not read %s", sha1_to_hex(sha1));
-
- root_tree = lookup_tree(rsha);
- if (!root_tree)
- die("Could not read %s", sha1_to_hex(sha1));
-
- /* Prepare a fake entry */
- root_entry.directory = 1;
- root_entry.executable = root_entry.symlink = 0;
- root_entry.mode = S_IFDIR;
- root_entry.name = "";
- root_entry.item.tree = root_tree;
- root_entry.parent = NULL;
-}
-
-static int prepare_children(struct tree_entry_list *elem)
-{
- if (!elem->directory)
- return -1;
- if (!elem->item.tree->object.parsed) {
- struct tree_entry_list *e;
- if (parse_tree(elem->item.tree))
- return -1;
- /* Set up the parent link */
- for (e = elem->item.tree->entries; e; e = e->next)
- e->parent = elem;
- }
- return 0;
-}
-
-static struct tree_entry_list *find_entry(const char *path, char *pathbuf)
-{
- const char *next, *slash;
- int len;
- struct tree_entry_list *elem = &root_entry, *oldelem = NULL;
-
- *(pathbuf) = '\0';
-
- /* Find tree element, descending from root, that
- * corresponds to the named path, lazily expanding
- * the tree if possible.
- */
-
- while (path) {
- /* The fact we still have path means that the caller
- * wants us to make sure that elem at this point is a
- * directory, and possibly descend into it. Even what
- * is left is just trailing slashes, we loop back to
- * here, and this call to prepare_children() will
- * catch elem not being a tree. Nice.
- */
- if (prepare_children(elem))
- return NULL;
-
- slash = strchr(path, '/');
- if (!slash) {
- len = strlen(path);
- next = NULL;
- }
- else {
- next = slash + 1;
- len = slash - path;
- }
- if (len) {
- if (oldelem) {
- pathbuf += sprintf(pathbuf, "%s/", oldelem->name);
- }
-
- /* (len == 0) if the original path was "drivers/char/"
- * and we have run already two rounds, having elem
- * pointing at the drivers/char directory.
- */
- elem = elem->item.tree->entries;
- while (elem) {
- if ((strlen(elem->name) == len) &&
- !strncmp(elem->name, path, len)) {
- /* found */
- break;
- }
- elem = elem->next;
- }
- if (!elem)
- return NULL;
-
- oldelem = elem;
- }
- path = next;
- }
-
- return elem;
-}
-
-static const char *entry_type(struct tree_entry_list *e)
-{
- return (e->directory ? "tree" : "blob");
-}
-
-static const char *entry_hex(struct tree_entry_list *e)
-{
- return sha1_to_hex(e->directory
- ? e->item.tree->object.sha1
- : e->item.blob->object.sha1);
-}
-
-/* forward declaration for mutually recursive routines */
-static int show_entry(struct tree_entry_list *, int, char *pathbuf);
-
-static int show_children(struct tree_entry_list *e, int level, char *pathbuf)
-{
- int oldlen = strlen(pathbuf);
-
- if (e != &root_entry)
- sprintf(pathbuf + oldlen, "%s/", e->name);
-
- if (prepare_children(e))
- die("internal error: ls-tree show_children called with non tree");
- e = e->item.tree->entries;
- while (e) {
- show_entry(e, level, pathbuf);
- e = e->next;
- }
-
- pathbuf[oldlen] = '\0';
-
- return 0;
-}
+static const char ls_tree_usage[] =
+ "git-ls-tree [-d] [-r] [-z] <tree-ish> [path...]";
-static int show_entry(struct tree_entry_list *e, int level, char *pathbuf)
+static int show_tree(unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage)
{
- int err = 0;
-
- if (e != &root_entry) {
- printf("%06o %s %s ",
- e->mode, entry_type(e), entry_hex(e));
- write_name_quoted(pathbuf, e->name, line_termination, stdout);
- putchar(line_termination);
- }
+ const char *type = "blob";
+ int retval = 0;
- if (e->directory) {
- /* If this is a directory, we have the following cases:
- * (1) This is the top-level request (explicit path from the
- * command line, or "root" if there is no command line).
- * a. Without any flag. We show direct children. We do not
- * recurse into them.
- * b. With -r. We do recurse into children.
- * c. With -d. We do not recurse into children.
- * (2) We came here because our caller is either (1-a) or
- * (1-b).
- * a. Without any flag. We do not show our children (which
- * are grandchildren for the original request).
- * b. With -r. We continue to recurse into our children.
- * c. With -d. We should not have come here to begin with.
- */
- if (level == 0 && !(ls_options & LS_TREE_ONLY))
- /* case (1)-a and (1)-b */
- err = err | show_children(e, level+1, pathbuf);
- else if (level && ls_options & LS_RECURSIVE)
- /* case (2)-b */
- err = err | show_children(e, level+1, pathbuf);
+ if (S_ISDIR(mode)) {
+ type = "tree";
+ if (ls_options & LS_RECURSIVE)
+ retval = READ_TREE_RECURSIVE;
}
- return err;
-}
-static int list_one(const char *path)
-{
- int err = 0;
- char pathbuf[MAXPATHLEN + 1];
- struct tree_entry_list *e = find_entry(path, pathbuf);
- if (!e) {
- /* traditionally ls-tree does not complain about
- * missing path. We may change this later to match
- * what "/bin/ls -a" does, which is to complain.
- */
- return err;
- }
- err = err | show_entry(e, 0, pathbuf);
- return err;
+ printf("%06o %s %s\t%.*s%s%c", mode, type, sha1_to_hex(sha1), baselen, base, pathname, line_termination);
+ return retval;
}
-static int list(char **path)
+int main(int argc, const char **argv)
{
- int i;
- int err = 0;
- for (i = 0; path[i]; i++)
- err = err | list_one(path[i]);
- return err;
-}
-
-static const char ls_tree_usage[] =
- "git-ls-tree [-d] [-r] [-z] <tree-ish> [path...]";
-
-int main(int argc, char **argv)
-{
- static char *path0[] = { "", NULL };
- char **path;
+ const char **path, *prefix;
unsigned char sha1[20];
+ char *buf;
+ unsigned long size;
+ prefix = setup_git_directory();
while (1 < argc && argv[1][0] == '-') {
switch (argv[1][1]) {
case 'z':
@@ -244,9 +61,11 @@ int main(int argc, char **argv)
if (get_sha1(argv[1], sha1) < 0)
usage(ls_tree_usage);
- path = (argc == 2) ? path0 : (argv + 2);
- prepare_root(sha1);
- if (list(path) < 0)
- die("list failed");
+ path = get_pathspec(prefix, argv + 2);
+ buf = read_object_with_reference(sha1, "tree", &size, NULL);
+ if (!buf)
+ die("not a tree object");
+ read_tree_recursive(buf, size, "", 0, 0, path, show_tree);
+
return 0;
}
diff --git a/tree.c b/tree.c
index 8b42a07..043f032 100644
--- a/tree.c
+++ b/tree.c
@@ -9,9 +9,16 @@ const char *tree_type = "tree";
static int read_one_entry(unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage)
{
- int len = strlen(pathname);
- unsigned int size = cache_entry_size(baselen + len);
- struct cache_entry *ce = xmalloc(size);
+ int len;
+ unsigned int size;
+ struct cache_entry *ce;
+
+ if (S_ISDIR(mode))
+ return READ_TREE_RECURSIVE;
+
+ len = strlen(pathname);
+ size = cache_entry_size(baselen + len);
+ ce = xmalloc(size);
memset(ce, 0, size);
@@ -67,9 +74,10 @@ static int match_tree_entry(const char *
return 0;
}
-static int read_tree_recursive(void *buffer, unsigned long size,
- const char *base, int baselen,
- int stage, const char **match)
+int read_tree_recursive(void *buffer, unsigned long size,
+ const char *base, int baselen,
+ int stage, const char **match,
+ read_tree_fn_t fn)
{
while (size) {
int len = strlen(buffer)+1;
@@ -86,6 +94,14 @@ static int read_tree_recursive(void *buf
if (!match_tree_entry(base, baselen, path, mode, match))
continue;
+ switch (fn(sha1, base, baselen, path, mode, stage)) {
+ case 0:
+ continue;
+ case READ_TREE_RECURSIVE:
+ break;;
+ default:
+ return -1;
+ }
if (S_ISDIR(mode)) {
int retval;
int pathlen = strlen(path);
@@ -106,22 +122,20 @@ static int read_tree_recursive(void *buf
retval = read_tree_recursive(eltbuf, eltsize,
newbase,
baselen + pathlen + 1,
- stage, match);
+ stage, match, fn);
free(eltbuf);
free(newbase);
if (retval)
return -1;
continue;
}
- if (read_one_entry(sha1, base, baselen, path, mode, stage) < 0)
- return -1;
}
return 0;
}
int read_tree(void *buffer, unsigned long size, int stage, const char **match)
{
- return read_tree_recursive(buffer, size, "", 0, stage, match);
+ return read_tree_recursive(buffer, size, "", 0, stage, match, read_one_entry);
}
struct tree *lookup_tree(const unsigned char *sha1)
diff --git a/tree.h b/tree.h
index 9975e88..768e5e9 100644
--- a/tree.h
+++ b/tree.h
@@ -35,4 +35,13 @@ int parse_tree(struct tree *tree);
/* Parses and returns the tree in the given ent, chasing tags and commits. */
struct tree *parse_tree_indirect(const unsigned char *sha1);
+#define READ_TREE_RECURSIVE 1
+typedef int (*read_tree_fn_t)(unsigned char *, const char *, int, const char *, unsigned int, int);
+
+extern int read_tree_recursive(void *buffer, unsigned long size,
+ const char *base, int baselen,
+ int stage, const char **match,
+ read_tree_fn_t fn);
+
+
#endif /* TREE_H */
^ permalink raw reply related
* Re: [PATCH 0/8] Make C-level operable from subdirectories
From: Ryan Anderson @ 2005-11-26 18:44 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, Johannes Schindelin, git
In-Reply-To: <7voe477n4i.fsf_-_@assigned-by-dhcp.cox.net>
On Sat, Nov 26, 2005 at 01:51:41AM -0800, Junio C Hamano wrote:
> Linus Torvalds <torvalds@osdl.org> writes:
>
> > On Fri, 25 Nov 2005, Junio C Hamano wrote:
> >>
> >> I once advocated for an environment to name the top of working
> >> tree directory --- it might make sense to resurrect that one.
> >
> > Please don't.
> >
> > We should just make the scripts do it automatically instead.
>
> Here comes an 8-patch series.
Should the documentation get an update to mention that using GIT_DIR to
create a totally out-of-tree setup is supported, but not recommended?
--
Ryan Anderson
sometimes Pug Majere
^ permalink raw reply
* Re: [PATCH 1/8] git-apply: work from subdirectory.
From: Junio C Hamano @ 2005-11-26 18:54 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0511260932080.13959@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> The only case where we care about a git directory is the "--index" case.
> In all other cases we should happily apply it (or stat it).
True. We should do the same as peek-remote.
^ permalink raw reply
* [PATCH] Cogito documentation updates
From: Jonas Fonseca @ 2005-11-26 19:12 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20051120101112.GA2302@diku.dk>
- note the difference between short and long help in cg-help(1)
- mention the alien repo importers provided by the git core
- fix typo in cg-update(1)
- fix help options for the cg(1) manpage
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
diff --git a/Documentation/make-cg-asciidoc b/Documentation/make-cg-asciidoc
index 00e4ce7..51db9e3 100755
--- a/Documentation/make-cg-asciidoc
+++ b/Documentation/make-cg-asciidoc
@@ -79,6 +79,21 @@ else
fi
fi
+# cg(1) does not answer to the help options in the same way as the
+# rest of the commands
+if [ "$COMMAND" = "cg" ]; then
+ HELP_OPTIONS="
+-h, --help::
+ Print overview of Cogito commands. Same as gitlink:cg-help[1]."
+else
+ HELP_OPTIONS="
+-h, --help::
+ Print usage summary.
+
+--long-help::
+ Print user manual. The same as found in $TITLE."
+fi
+
cat <<__END__
$TITLE
$TITLELINE
@@ -98,12 +113,7 @@ $DESCRIPTION
OPTIONS
-------
$OPTIONS
-
--h, --help::
- Print usage summary.
-
---long-help::
- Print user manual. The same as found in $TITLE.
+$HELP_OPTIONS
$MISC
@@ -113,6 +123,6 @@ $COPYRIGHT
SEE ALSO
--------
-$COMMAND command is part of gitlink:${PACKAGE}[7],
+$COMMAND is part of gitlink:${PACKAGE}[7],
a toolkit for managing gitlink:git[7] trees.
__END__
diff --git a/cg-add b/cg-add
index a50c0ac..4611930 100755
--- a/cg-add
+++ b/cg-add
@@ -25,9 +25,8 @@
# -r:: Add files recursively
# If you pass cg-add this flag and any directory names, it will try
# to add files in those directories recursively (with regard to your
-# ignore rules - see cg-status documentation for more detailed
-# description of those). See also above for more notes about cg-add
-# vs. directories.
+# ignore rules - see `cg-status` for a more detailed description of
+# those). See also above for more notes about cg-add vs. directories.
USAGE="cg-add [-N] [-r] FILE..."
diff --git a/cg-help b/cg-help
index 6ba7657..5fa65ef 100755
--- a/cg-help
+++ b/cg-help
@@ -8,8 +8,9 @@
# If the argument is left out an overview of all the Cogito commands will
# be shown.
#
-# Note help for a command is also available by passing `--help` or `-h`
-# to the command.
+# Note, short help for a command is also available by passing `--help` or
+# `-h` to the command. The complete command manual is shown when passing
+# `--long-help` (and is the same as doing "`cg-help command`").
#
# OPTIONS
# -------
diff --git a/cg-init b/cg-init
index a0a7372..31c2e10 100755
--- a/cg-init
+++ b/cg-init
@@ -9,7 +9,9 @@
# This command is intended for creating repositories for work on new projects.
# If you want to clone an existing project, see `cg-clone`. If you want to
# set up a public repository not for direct work but only for pushing/pulling,
-# see `cg-admin-setuprepo`.
+# see `cg-admin-setuprepo`. It is also possible to import repositories from
+# other SCMs into GIT, see `git-cvsimport(1)`, `git-svnimport(1)` and
+# `git-archimport(1)`.
#
# OPTIONS
# -------
diff --git a/cg-update b/cg-update
index ed93c01..9d82fcb 100755
--- a/cg-update
+++ b/cg-update
@@ -8,7 +8,7 @@
# This is similar to running cg-fetch and cg-merge commands successively.
# Please refer to the documentation of those commands for more details
# about the operation. Note that if you are not doing own development
-# but only following some project, you it is recommended to use this command
+# but only following some project, it is recommended to use this command
# instead of `cg-fetch` + `cg-merge` since `cg-update` can handle some
# additional corner cases (in particular, if the remote branch rebases,
# `cg-update` will fast-forward instead of doing a tree merge and diverging).
--
Jonas Fonseca
^ permalink raw reply related
* Re: git-send-mail in sh
From: Junio C Hamano @ 2005-11-26 20:12 UTC (permalink / raw)
To: Andreas Ericsson; +Cc: git
In-Reply-To: <43874935.2080804@op5.se>
Subject: [PATCH] format-patch: output filename reported to stdout verbatim.
Prepending asterisk to the output was just adding noise, and
forcing scripts like git-send-mail proposed by Andreas Ericsson
do unnecessary work.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Andreas Ericsson <ae@op5.se> writes:
> Junio C Hamano wrote:
>
>> ... If the standard output from format-patch is useful like
>> this, I would like to drop the '* ' prefix from it, so that you
>> do not have to sed it out.
>
> I'll do that then. It doesn't really add any value anyways.
Agreed, so I'll push this out in the next batch.
git-format-patch.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
applies-to: 9ccf8849fa9b522a344645c2f28f12ab036e30d5
51b3c00e9d95371a9ad202204f01c5981f241b20
diff --git a/git-format-patch.sh b/git-format-patch.sh
index bc56876..9b40880 100755
--- a/git-format-patch.sh
+++ b/git-format-patch.sh
@@ -268,7 +268,7 @@ do
file=`printf '%04d-%stxt' $i "$title"`
if test '' = "$stdout"
then
- echo "* $file"
+ echo "$file"
process_one >"$outdir$file"
if test t = "$check"
then
@@ -279,7 +279,7 @@ do
:
fi
else
- echo >&2 "* $file"
+ echo >&2 "$file"
process_one
fi
i=`expr "$i" + 1`
---
@@GIT_VERSION@@
^ permalink raw reply related
* Re: [PATCH 1/9] archimport: first, make sure it still compiles
From: Eric Wong @ 2005-11-26 20:43 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Martin Langhoff, git list, Martin Langhoff
In-Reply-To: <Pine.LNX.4.64.0511241051170.13959@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> wrote:
>
>
> Eric,
> I don't know about Junio, but if I were him, I'd have preferred that all
> your patches had a
>
> archimport: ..
>
> prefix in the subject line, not just the first one.
Good idea, will do for future patches.
--
Eric Wong
^ permalink raw reply
* Re: simple git repository browser with vim
From: Eric Wong @ 2005-11-26 22:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v8xveuyq0.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
> Eric Wong <normalperson@yhbt.net> writes:
>
> > It relies on a simple shell script I wrote called 'git-show' that picks
> > a reasonable way to display each of the blob, tree, or commit object
> > types. I'm fairly sure somebody else has written something like
> > git-show before, I just couldn't find it. I'd imagine it's pretty
> > useful standalone without vim, too.
>
> Aha.
>
> It strikes me that the blob case could be enhanced to do
> git-unpack-file, run "file -i" on it to figure out the file's
> mimetype, and then give it to an appropriate MIME type viewer
> ;-).
Maybe somebody else will find this useful, overkill for me.
> For a tag object, you might want to deref it, and also if it is
> a signed kind, you may want to do git-verify-tag it.
This is pretty useful, I've added it to my version, and also added
extra vim foldmarkers for the dereferenced tag.
> The following should not taken too seriously, but you might find
> it instructive to learn how to unwrap tag objects, verify them
> for signature, and pretty-print a single commit without running
> whatchanged. I suspect the script as posted by you shows the
> commit message twice, BTW.
That was semi-intentional, I wanted the short diff format with the
sha1sums of the blobs so I could further expand those inside vim.
Fortunately, I've figured out that diff-tree is better for this.
Here's what I'm currently using:
---
#!/bin/sh
extract_tag_info='
s/^object /sha1=/p
/^type /{
s//type=/
p
q
}
'
sha1sums=
while : ; do
case "$1" in
-f|--fold-marker)
fold_marker=1
;;
*)
sha1sums="$sha1sums $1"
break
;;
esac
shift
done
for sha1 in $sha1sums
do
type=`git-cat-file -t $sha1` || continue
test -n "$fold_marker" && echo "$type($1) {{{"
while case "$type" in tag) ;; *) break ;; esac
do
git-cat-file tag "$sha1"
git-verify-tag "$sha1"
test -n "$fold_marker" && echo '}}}'
eval `git-cat-file tag "$sha1" | sed -n -e "$extract_tag_info"`
test -n "$fold_marker" && echo "$type($1) {{{"
done
case "$type" in
tree)
git-ls-tree -r "$sha1"
;;
blob)
git-cat-file blob "$sha1"
;;
commit)
git-diff-tree --pretty=raw -r -m -C --find-copies-harder "$sha1"
test -n "$fold_marker" && echo "commit_diff($1) {{{"
git-diff-tree -m -C --find-copies-harder -p "$sha1"
test -n "$fold_marker" && echo '}}}'
;;
esac
test -n "$fold_marker" && echo '}}}'
done
^ permalink raw reply
* [PATCH] Document the --(no-)edit switch of git-revert and git-cherry-pick
From: Petr Baudis @ 2005-11-26 22:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
This switch was not documented properly. I decided not to mention
the --no-edit switch in the git-cherry-pick documentation since
we always default to no editing.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
Documentation/git-cherry-pick.txt | 6 +++++-
Documentation/git-revert.txt | 11 ++++++++++-
git-revert.sh | 4 ++--
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index 26e0467..5e0ef5a 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -7,7 +7,7 @@ git-cherry-pick - Apply the change intro
SYNOPSIS
--------
-'git-cherry-pick' [-n] [-r] <commit>
+'git-cherry-pick' [--edit] [-n] [-r] <commit>
DESCRIPTION
-----------
@@ -20,6 +20,10 @@ OPTIONS
<commit>::
Commit to cherry-pick.
+--edit::
+ With this option, `git-cherry-pick` will let you edit the commit
+ message prior committing.
+
-r::
Usually the command appends which commit was
cherry-picked after the original commit message when
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index feebd81..f471037 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -7,7 +7,7 @@ git-revert - Revert an existing commit.
SYNOPSIS
--------
-'git-revert' [-n] <commit>
+'git-revert' [--edit | --no-edit] [-n] <commit>
DESCRIPTION
-----------
@@ -20,6 +20,15 @@ OPTIONS
<commit>::
Commit to revert.
+--edit::
+ With this option, `git-revert` will let you edit the commit
+ message prior committing the revert. This is the default if
+ you run the command from a terminal.
+
+--no-edit::
+ With this option, `git-revert` will not start the commit
+ message editor.
+
-n::
Usually the command automatically creates a commit with
a commit log message stating which commit was reverted.
diff --git a/git-revert.sh b/git-revert.sh
index c1aebb1..5cb02b1 100755
--- a/git-revert.sh
+++ b/git-revert.sh
@@ -19,10 +19,10 @@ esac
usage () {
case "$me" in
cherry-pick)
- die "usage git $me [-n] [-r] <commit-ish>"
+ die "usage git $me [--edit] [-n] [-r] <commit-ish>"
;;
revert)
- die "usage git $me [-n] <commit-ish>"
+ die "usage git $me [--edit | --no-edit] [-n] <commit-ish>"
;;
esac
}
^ permalink raw reply related
* Re: git-send-mail in sh
From: Andreas Ericsson @ 2005-11-26 22:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vwtiwmvfp.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
> Andreas Ericsson <ae@op5.se> writes:
>
>
>>It doesn't CC them, but any number of email-addresses can be specified
>>on the command line (so long as they don't include spaces, but that can
>>be taken care of).
>
>
> Again I do not think I'd ever use that feature from the original
> send-email myself, but the difference is that this CC list
> depends on each commit (sign-offs taken from a commit are
> added to CC list for only that commit).
>
Had a thinko when I wrote that. I've added --cc-signers, --cc-author and
--cc (for both --cc-signers and --cc-author).
> But you are right. We could make a single <commit> a short-hand
> for "origin"..<commit>;
Actually, I meant that a single <commit> would mean "<commit>..HEAD",
like git-format-patch does it. Doing the other way around in a tool so
closely coupled would be very confusing, I think.
Here's what I have on disk right now. The ${var##*^} syntax was decided
to be portable in some earlier discussion, so I'm sticking with it
(mostly because I don't know how to do it with expr and Junio pokes me
when I do it with sed. Enlightenment welcome).
if [ "$com2" ]; then
range="$com1..$com2"
else
case "$com1" in
?*..?*)
# nicely ranged already
range="$com1"
;;
..)
range=origin..HEAD
;;
?*^)
# single commit
com1="${com1##*^}"
range="$com1^1..$com1"
;;
?*^[0-9]|?*^[0-9][0-9])
# series of commits, ranging back from <commit-ish>
range="$com1..${com1%%^*}"
;;
^[0-9]|^[0-9][0-9])
# series of commits, ranging back from HEAD
range="HEAD$com1..HEAD"
;;
*)
range="$com1..HEAD"
;;
esac
fi
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply
* Re: git-send-mail in sh
From: Yann Dirson @ 2005-11-26 23:34 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Andreas Ericsson, git
In-Reply-To: <7v7jaxou5b.fsf@assigned-by-dhcp.cox.net>
On Fri, Nov 25, 2005 at 03:15:44AM -0800, Junio C Hamano wrote:
> > function usage() {
> > echo "Usage: git submit upstream@email.org <commit-ish> [<commit-ish>]"
> > exit 1
> > }
>
> I'm old fashioned and tend to omit noise word "function".
More importantly, it is not portable.
--
Yann Dirson <ydirson@altern.org> |
Debian-related: <dirson@debian.org> | Support Debian GNU/Linux:
| Freedom, Power, Stability, Gratis
http://ydirson.free.fr/ | Check <http://www.debian.org/>
^ permalink raw reply
* Re: Get rid of .git/branches/ and .git/remotes/?
From: Petr Baudis @ 2005-11-26 23:50 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Linus Torvalds, git
In-Reply-To: <Pine.LNX.4.63.0511202039340.23586@wbgn013.biozentrum.uni-wuerzburg.de>
Dear diary, on Sun, Nov 20, 2005 at 08:50:41PM CET, I got a letter
where Johannes Schindelin <Johannes.Schindelin@gmx.de> said that...
> > And I'm not 100% convinced that putting these branches in the config file
> > has any real advantages over keeping them as separate files. Having
> > everything in one place is nice, of course, and being able to copy just
> > one file around might be convenient, but it _does_ make the config file
> > more complicated.
>
> And it _does_ make finding the information for less savvy git users more
> easy.
Is that so?
I'm not 50% convinced, but if people are excited about it, I can live
with it; in that case I would like appropriately powerful
git-repo-config, though - so that I can say "list me all branch.*
section names". Surely I could play some ugly grep games, but ideally,
I would like to avoid peeking into the .git/config file directly
altogether in Cogito - call that proper layering. ;-)
> I'm not 100% convinced, either, but it could be a better concept than
> different files in different places and different formats basically doing
> the same.
>
> But my thinking went like this: if Pasky and Junio can not agree on one
> location and format, and therefore none of the two is deprecated, how
> about giving them a way out they both might be able to agree to?
Now, those are just different concepts. Cogito's "branch" concept maps
single local head to a single remote head, 1:1. GIT's "remote" concept
maps (possibly not well-defined) bunch of local heads to a remote
repository (where they have same or different name) or a piece of it; to
accomplish this, it introduces a whole new rather complicated concept,
which nevertheless in part shares the namespace with heads (branches).
Surely, remotes are more flexible, but from the end-user perspective
they really act just as kind of "macros" compared to branches, except
that it's faster when you fetch multiple branches at once than when you
do it in sequence. I might add support for multibranch fetches to
Cogito, and I still intend to implement "readonly" remotes support for
the sake of compatibility with GIT, but I plan to stick to branches
otherwise. It's confusing enough to have remote and local heads, and
actually remotes make it even more confusing since you direct your
"direct touch" with the remote heads, now covered in some more abstract
entity.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.
^ permalink raw reply
* Re: Get rid of .git/branches/ and .git/remotes/?
From: Junio C Hamano @ 2005-11-27 0:38 UTC (permalink / raw)
To: git; +Cc: Petr Baudis
In-Reply-To: <20051126235011.GA22159@pasky.or.cz>
Petr Baudis <pasky@suse.cz> writes:
>> But my thinking went like this: if Pasky and Junio can not agree on one
>> location and format, and therefore none of the two is deprecated, how
>> about giving them a way out they both might be able to agree to?
>
> Now, those are just different concepts. Cogito's "branch" concept maps
> single local head to a single remote head, 1:1. GIT's "remote" concept
> maps (possibly not well-defined) bunch of local heads to a remote
> repository (where they have same or different name) or a piece of it...
I agree. They are simply different things and serve different
audiences.
When you are asked to pull from somebody else (and when you are
playing an integrator role, not an individual developer role,
you will be asked to pull from different people) you may not
want to immediately pull into your master branch. I usually
either do "git checkout -b throwaway master" and pull into it,
or run "git fetch remote master:throwaway" followed by "git diff
master throwaway" to see what I'll be getting. When you set up
one "remotes" file is when you realize that you are pulling this
way from the same place number of times, to reduce future
typing. So as Pasky says, it is exactly "macro" and not "per
branch configuration". It is just "per remote shorthand".
Cogito "branch" matches very naturally to what an individual
developer might want to do. You have one branch that you use to
do your work tracking one upstream. You can of course have more
than one upstream and branch, but the most typical usage would
be traditional CVS style setup to get updates from the central
location (described in branches/* file), fetch and merge from
there and push your changes back. It is very well designed to
support this pattern of usage.
It may not make much sense for an integrator-role person to have
branches/master file to configure his "master" branch that
points at the URL of only one of his subsystem maintainers. An
integrator-role person does not need "per branch" configuration
in that sense. On the other hand "remotes" may help if the
integrator-role person regularly pulls from the same set of
subsystem maintainers.
Of course, an individual developer can set up a single remotes
file that describes the single upstream, fetching
"master:origin" and merging into his "master"; what "remotes"
file used that way does not give us, unlike "branch" of Cogito,
is that it does not say on which local branch that fetching and
merging happens.
^ permalink raw reply
* Re: Rss produced by git is not valid xml?
From: Junio C Hamano @ 2005-11-27 3:57 UTC (permalink / raw)
To: Kay Sievers; +Cc: Linus Torvalds, git
In-Reply-To: <20051127025249.GA12286@vrfy.org>
Kay Sievers <kay.sievers@vrfy.org> writes:
> On Sat, Nov 19, 2005 at 09:52:34AM -0800, Linus Torvalds wrote:
>>
>> On Sat, 19 Nov 2005, Junio C Hamano wrote:
>> >
>> > Well, some people on the list seem to think UTF-8 is the one and
>> > only right encoding, so for them if the message does not
>> > identify what it is in, assuming UTF-8 and not doing any
>> > conversion is probably the right thing ;-).
>>
>> If you replace "assume" with "verify", then I agree.
One problem I have that approach is what to do if it does not
verify. Reject and ask them to re-run the program with another
option --binary-log-message?
> I found some test code I did a while ago for validation of
> filesystem labels, cause D-BUS diconnects your session, if you
> send an invalid utf-8 string to the bus. :)
>
> Kay
Thanks. I take it that you are licensing this code to use in
git when we doing what Linus suggests?
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox