git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Add quiet option to git-ls-files
Date: Fri, 8 Jan 2010 01:07:20 +0530	[thread overview]
Message-ID: <f3271551001071137u6158fa4fm1bf7a51a83354574@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 163 bytes --]

Hi,

I just wrote a couple of patches. I'm sorry for having to attach the
files- I'm behind a HTTP proxy, and Gmail mangles patches.

Thanks and regards,
Ramkumar

[-- Attachment #2: 0001-Add-quiet-option-to-git-ls-files.patch --]
[-- Type: text/x-patch, Size: 2284 bytes --]

From f5f76190a833bf105483a7da9b4b61ab03e373ba Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon@gmail.com>
Date: Thu, 7 Jan 2010 23:58:08 +0530
Subject: [PATCH 1/2] Add quiet option to git-ls-files

--quiet option suppresses error output in --error-unmatch mode. Modify
documentation to reflect changes.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 Documentation/git-ls-files.txt |    6 ++++++
 builtin-ls-files.c             |   12 +++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index 625723e..0a1f94e 100644
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -82,6 +82,12 @@ OPTIONS
 	Skips files matching pattern.
 	Note that pattern is a shell wildcard pattern.
 
+--q::
+--quiet::
+	Only meaningful in --error-unmatch mode. Do not output an
+	error message if <file> does not appear in the index. Instead
+	exit with non-zero status silently.
+
 -X <file>::
 --exclude-from=<file>::
 	exclude patterns are read from <file>; 1 per line.
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index c9a03e5..40560da 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -421,12 +421,13 @@ static int option_parse_exclude_standard(const struct option *opt,
 
 int cmd_ls_files(int argc, const char **argv, const char *prefix)
 {
-	int require_work_tree = 0, show_tag = 0;
+	int require_work_tree = 0, show_tag = 0, quiet = 0;
 	struct dir_struct dir;
 	struct option builtin_ls_files_options[] = {
 		{ OPTION_CALLBACK, 'z', NULL, NULL, NULL,
 			"paths are separated with NUL character",
 			PARSE_OPT_NOARG, option_parse_z },
+		OPT__QUIET(&quiet),
 		OPT_BOOLEAN('t', NULL, &show_tag,
 			"identify the file status with tags"),
 		OPT_BOOLEAN('v', NULL, &show_valid_bit,
@@ -547,10 +548,11 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
 
 	if (ps_matched) {
 		int bad;
-		bad = report_path_error(ps_matched, pathspec, prefix_offset);
-		if (bad)
-			fprintf(stderr, "Did you forget to 'git add'?\n");
-
+		if (!quiet) {
+			bad = report_path_error(ps_matched, pathspec, prefix_offset);
+			if (bad)
+				fprintf(stderr, "Did you forget to 'git add'?\n");
+		}
 		return bad ? 1 : 0;
 	}
 
-- 
1.6.5


[-- Attachment #3: 0002-Replace-redirect-to-dev-null-in-favor-of-quiet-optio.patch --]
[-- Type: text/x-patch, Size: 3664 bytes --]

From b5c7a0fb8d092aafcedcbd653f00dee564a0d953 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon@gmail.com>
Date: Fri, 8 Jan 2010 00:00:58 +0530
Subject: [PATCH 2/2] Replace redirect to /dev/null in favor of quiet option

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 git-mergetool.sh |    2 +-
 git-pull.sh      |    2 +-
 git-rebase.sh    |    2 +-
 git-stash.sh     |   12 ++++++------
 git-submodule.sh |    2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/git-mergetool.sh b/git-mergetool.sh
index b52a741..1c902aa 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -101,7 +101,7 @@ resolve_deleted_merge () {
 		return 0
 		;;
 	    [dD]*)
-		git rm -- "$MERGED" > /dev/null
+		git rm --quiet -- "$MERGED"
 		cleanup_temp_files
 		return 0
 		;;
diff --git a/git-pull.sh b/git-pull.sh
index 9e69ada..336e91a 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -170,7 +170,7 @@ test true = "$rebase" && {
 	. git-parse-remote &&
 	remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
 	oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&
-	for reflog in $(git rev-list -g $remoteref 2>/dev/null)
+	for reflog in $(git rev-list --quiet --walk-reflogs $remoteref)
 	do
 		if test "$reflog" = "$(git merge-base $reflog $curr_branch)"
 		then
diff --git a/git-rebase.sh b/git-rebase.sh
index b121f45..bfe0475 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -100,7 +100,7 @@ call_merge () {
 	cmt="$(cat "$dotest/cmt.$1")"
 	echo "$cmt" > "$dotest/current"
 	hd=$(git rev-parse --verify HEAD)
-	cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
+	cmt_name=$(git symbolic-ref --quiet HEAD || echo HEAD)
 	msgnum=$(cat "$dotest/msgnum")
 	end=$(cat "$dotest/end")
 	eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
diff --git a/git-stash.sh b/git-stash.sh
index 3a0685f..5605d19 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -39,7 +39,7 @@ clear_stash () {
 	then
 		die "git stash clear with parameters is unimplemented"
 	fi
-	if current=$(git rev-parse --verify $ref_stash 2>/dev/null)
+	if current=$(git rev-parse --quiet --verify $ref_stash)
 	then
 		git update-ref -d $ref_stash $current
 	fi
@@ -200,7 +200,7 @@ save_stash () {
 }
 
 have_stash () {
-	git rev-parse --verify $ref_stash >/dev/null 2>&1
+	git rev-parse --quiet --verify $ref_stash >/dev/null
 }
 
 list_stash () {
@@ -337,16 +337,16 @@ drop_stash () {
 	fi
 	# Verify supplied argument looks like a stash entry
 	s=$(git rev-parse --verify "$@") &&
-	git rev-parse --verify "$s:"   > /dev/null 2>&1 &&
-	git rev-parse --verify "$s^1:" > /dev/null 2>&1 &&
-	git rev-parse --verify "$s^2:" > /dev/null 2>&1 ||
+	git rev-parse --quiet --verify "$s:"   > /dev/null &&
+	git rev-parse --quiet --verify "$s^1:" > /dev/null &&
+	git rev-parse --quiet --verify "$s^2:" > /dev/null ||
 		die "$*: not a valid stashed state"
 
 	git reflog delete --updateref --rewrite "$@" &&
 		say "Dropped $* ($s)" || die "$*: Could not drop stash entry"
 
 	# clear_stash if we just dropped the last stash entry
-	git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash
+	git rev-parse --quiet --verify "$ref_stash@{0}" > /dev/null || clear_stash
 }
 
 apply_to_branch () {
diff --git a/git-submodule.sh b/git-submodule.sh
index 77d2232..2b6448f 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -196,7 +196,7 @@ cmd_add()
 			tstart
 			s|/*$||
 		')
-	git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
+	git ls-files --quiet --error-unmatch "$path" > /dev/null &&
 	die "'$path' already exists in the index"
 
 	# perhaps the path exists and is already a git repo, else clone it
-- 
1.6.5


             reply	other threads:[~2010-01-07 19:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-07 19:37 Ramkumar Ramachandra [this message]
2010-01-07 20:19 ` [PATCH] Add quiet option to git-ls-files Junio C Hamano
2010-01-08  2:17   ` Ramkumar Ramachandra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3271551001071137u6158fa4fm1bf7a51a83354574@mail.gmail.com \
    --to=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).