{"thread":{"id":"39208","subject":"[PATCH v1] Improving code base readability","startedAt":"2015-05-01T15:28:44Z","lastAt":"2015-05-01T15:28:44Z","messageCount":1,"participants":["Alangi Derick"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"260344","messageId":"CAKB+oNvMhvT4KWwV5ohi9hfAs1Jzt7-zYhbSZ6RLzO6Zex5gtA@mail.gmail.com","threadId":"39208","inReplyTo":null,"subject":"[PATCH v1] Improving code base readability","fromName":"Alangi Derick","fromEmail":"alangiderick@gmail.com","sentAt":"2015-05-01T15:28:44Z","receivedAt":"2015-05-01T15:28:44Z","isPatch":true,"sender":{"key":"alangiderick@gmail.com","avatar":"https://gravatar.com/avatar/f5878e69e83b4cf7ed499336c4a114dc2cb253253bc57c9b8ffcf0e129320795?d=mp&s=160"},"body":"This is an example of what i am talking about or what i am trying to\ndemonstrate. This is the patch:\n\n---\n archive-tar.c   | 10 +++++-----\n archive-zip.c   | 12 ++++++------\n base85.c        | 14 +++++++-------\n builtin/mv.c    |  4 ++--\n builtin/notes.c | 36 ++++++++++++++++++------------------\n builtin/prune.c |  6 +++---\n builtin/push.c  |  6 +++---\n git.c           |  2 +-\n 8 files changed, 45 insertions(+), 45 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 0d1e6bd..c5d64aa 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -102,7 +102,7 @@ static int stream_blocked(const unsigned char *sha1)\n\n  st = open_istream(sha1, &type, &sz, NULL);\n  if (!st)\n- return error(\"cannot stream blob %s\", sha1_to_hex(sha1));\n+ return error(\"Cannot stream blob %s\", sha1_to_hex(sha1));\n  for (;;) {\n  readlen = read_istream(st, buf, sizeof(buf));\n  if (readlen <= 0)\n@@ -224,7 +224,7 @@ static int write_tar_entry(struct archiver_args *args,\n  *header.typeflag = TYPEFLAG_REG;\n  mode = (mode | ((mode & 0100) ? 0777 : 0666)) & ~tar_umask;\n  } else {\n- return error(\"unsupported file mode: 0%o (SHA1: %s)\",\n+ return error(\"Unsupported file mode: 0%o (SHA1: %s)\",\n      mode, sha1_to_hex(sha1));\n  }\n  if (pathlen > sizeof(header.name)) {\n@@ -251,7 +251,7 @@ static int write_tar_entry(struct archiver_args *args,\n  enum object_type type;\n  buffer = sha1_file_to_archive(args, path, sha1, old_mode, &type, &size);\n  if (!buffer)\n- return error(\"cannot read %s\", sha1_to_hex(sha1));\n+ return error(\"Cannot read %s\", sha1_to_hex(sha1));\n  } else {\n  buffer = NULL;\n  size = 0;\n@@ -413,10 +413,10 @@ static int write_tar_filter_archive(const struct\narchiver *ar,\n  filter.in = -1;\n\n  if (start_command(&filter) < 0)\n- die_errno(\"unable to start '%s' filter\", argv[0]);\n+ die_errno(\"Unable to start '%s' filter\", argv[0]);\n  close(1);\n  if (dup2(filter.in, 1) < 0)\n- die_errno(\"unable to redirect descriptor\");\n+ die_errno(\"Unable to redirect descriptor\");\n  close(filter.in);\n\n  r = write_tar_archive(ar, args);\ndiff --git a/archive-zip.c b/archive-zip.c\nindex ffb3535..18eef04 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -234,7 +234,7 @@ static int write_zip_entry(struct archiver_args *args,\n  }\n\n  if (pathlen > 0xffff) {\n- return error(\"path too long (%d chars, SHA1: %s): %s\",\n+ return error(\"Path too long (%d chars, SHA1: %s): %s\",\n  (int)pathlen, sha1_to_hex(sha1), path);\n  }\n\n@@ -258,7 +258,7 @@ static int write_zip_entry(struct archiver_args *args,\n     size > big_file_threshold) {\n  stream = open_istream(sha1, &type, &size, NULL);\n  if (!stream)\n- return error(\"cannot stream blob %s\",\n+ return error(\"Cannot stream blob %s\",\n      sha1_to_hex(sha1));\n  flags |= ZIP_STREAM;\n  out = buffer = NULL;\n@@ -266,7 +266,7 @@ static int write_zip_entry(struct archiver_args *args,\n  buffer = sha1_file_to_archive(args, path, sha1, mode,\n       &type, &size);\n  if (!buffer)\n- return error(\"cannot read %s\",\n+ return error(\"Cannot read %s\",\n      sha1_to_hex(sha1));\n  crc = crc32(crc, buffer, size);\n  is_binary = entry_is_binary(path_without_prefix,\n@@ -275,7 +275,7 @@ static int write_zip_entry(struct archiver_args *args,\n  }\n  compressed_size = (method == 0) ? size : 0;\n  } else {\n- return error(\"unsupported file mode: 0%o (SHA1: %s)\", mode,\n+ return error(\"Unsupported file mode: 0%o (SHA1: %s)\", mode,\n  sha1_to_hex(sha1));\n  }\n\n@@ -385,7 +385,7 @@ static int write_zip_entry(struct archiver_args *args,\n  zstream.avail_in = readlen;\n  result = git_deflate(&zstream, 0);\n  if (result != Z_OK)\n- die(\"deflate error (%d)\", result);\n+ die(\"Deflate error (%d)\", result);\n  out_len = zstream.next_out - compressed;\n\n  if (out_len > 0) {\n@@ -404,7 +404,7 @@ static int write_zip_entry(struct archiver_args *args,\n  zstream.avail_in = 0;\n  result = git_deflate(&zstream, Z_FINISH);\n  if (result != Z_STREAM_END)\n- die(\"deflate error (%d)\", result);\n+ die(\"Deflate error (%d)\", result);\n\n  git_deflate_end(&zstream);\n  out_len = zstream.next_out - compressed;\ndiff --git a/base85.c b/base85.c\nindex 5ca601e..9142940 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -50,17 +50,17 @@ int decode_85(char *dst, const char *buffer, int len)\n  ch = *buffer++;\n  de = de85[ch];\n  if (--de < 0)\n- return error(\"invalid base85 alphabet %c\", ch);\n+ return error(\"Invalid base85 alphabet %c\", ch);\n  acc = acc * 85 + de;\n  } while (--cnt);\n  ch = *buffer++;\n  de = de85[ch];\n  if (--de < 0)\n- return error(\"invalid base85 alphabet %c\", ch);\n+ return error(\"Invalid base85 alphabet %c\", ch);\n  /* Detect overflow. */\n  if (0xffffffff / 85 < acc ||\n     0xffffffff - de < (acc *= 85))\n- return error(\"invalid base85 sequence %.5s\", buffer-5);\n+ return error(\"Invalid base85 sequence %.5s\", buffer-5);\n  acc += de;\n  say1(\" %08x\", acc);\n\n@@ -78,7 +78,7 @@ int decode_85(char *dst, const char *buffer, int len)\n\n void encode_85(char *buf, const unsigned char *data, int bytes)\n {\n- say(\"encode 85\");\n+ say(\"Encode 85\");\n  while (bytes) {\n  unsigned acc = 0;\n  int cnt;\n@@ -111,7 +111,7 @@ int main(int ac, char **av)\n  encode_85(buf, av[2], len);\n  if (len <= 26) len = len + 'A' - 1;\n  else len = len + 'a' - 26 - 1;\n- printf(\"encoded: %c%s\\n\", len, buf);\n+ printf(\"Encoded: %c%s\\n\", len, buf);\n  return 0;\n  }\n  if (!strcmp(av[1], \"-d\")) {\n@@ -119,13 +119,13 @@ int main(int ac, char **av)\n  if ('A' <= len && len <= 'Z') len = len - 'A' + 1;\n  else len = len - 'a' + 26 + 1;\n  decode_85(buf, av[2]+1, len);\n- printf(\"decoded: %.*s\\n\", len, buf);\n+ printf(\"Decoded: %.*s\\n\", len, buf);\n  return 0;\n  }\n  if (!strcmp(av[1], \"-t\")) {\n  char t[4] = { -1,-1,-1,-1 };\n  encode_85(buf, t, 4);\n- printf(\"encoded: D%s\\n\", buf);\n+ printf(\"Encoded: D%s\\n\", buf);\n  return 0;\n  }\n }\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex d1d4316..c4b8a43 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -148,7 +148,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n  destination = internal_copy_pathspec(dest_path[0], argv, argc, DUP_BASENAME);\n  } else {\n  if (argc != 1)\n- die(_(\"destination '%s' is not a directory\"), dest_path[0]);\n+ die(_(\"Destination '%s' is not a directory\"), dest_path[0]);\n  destination = dest_path;\n  }\n\n@@ -253,7 +253,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n  printf(_(\"Renaming %s to %s\\n\"), src, dst);\n  if (!show_only && mode != INDEX) {\n  if (rename(src, dst) < 0 && !ignore_errors)\n- die_errno(_(\"renaming '%s' failed\"), src);\n+ die_errno(_(\"Renaming '%s' failed\"), src);\n  if (submodule_gitfile[i]) {\n  if (submodule_gitfile[i] != SUBMODULE_WITH_GITDIR)\n  connect_work_tree_and_git_dir(dst, submodule_gitfile[i]);\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 63f95fc..aa69b7f 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -143,11 +143,11 @@ static void write_commented_object(int fd, const\nunsigned char *object)\n  show.err = 0;\n  show.git_cmd = 1;\n  if (start_command(&show))\n- die(_(\"unable to start 'show' for object '%s'\"),\n+ die(_(\"Unable to start 'show' for object '%s'\"),\n     sha1_to_hex(object));\n\n  if (strbuf_read(&buf, show.out, 0) < 0)\n- die_errno(_(\"could not read 'show' output\"));\n+ die_errno(_(\"Could not read 'show' output\"));\n  strbuf_add_commented_lines(&cbuf, buf.buf, buf.len);\n  write_or_die(fd, cbuf.buf, cbuf.len);\n\n@@ -155,7 +155,7 @@ static void write_commented_object(int fd, const\nunsigned char *object)\n  strbuf_release(&buf);\n\n  if (finish_command(&show))\n- die(_(\"failed to finish 'show' for object '%s'\"),\n+ die(_(\"Failed to finish 'show' for object '%s'\"),\n     sha1_to_hex(object));\n }\n\n@@ -170,7 +170,7 @@ static void prepare_note_data(const unsigned char\n*object, struct note_data *d,\n  d->edit_path = git_pathdup(\"NOTES_EDITMSG\");\n  fd = open(d->edit_path, O_CREAT | O_TRUNC | O_WRONLY, 0600);\n  if (fd < 0)\n- die_errno(_(\"could not create file '%s'\"), d->edit_path);\n+ die_errno(_(\"Could not create file '%s'\"), d->edit_path);\n\n  if (d->given)\n  write_or_die(fd, d->buf.buf, d->buf.len);\n@@ -198,7 +198,7 @@ static void prepare_note_data(const unsigned char\n*object, struct note_data *d,\n static void write_note_data(struct note_data *d, unsigned char *sha1)\n {\n  if (write_sha1_file(d->buf.buf, d->buf.len, blob_type, sha1)) {\n- error(_(\"unable to write note object\"));\n+ error(_(\"Unable to write note object\"));\n  if (d->edit_path)\n  error(_(\"The note contents have been left in %s\"),\n  d->edit_path);\n@@ -228,9 +228,9 @@ static int parse_file_arg(const struct option\n*opt, const char *arg, int unset)\n  strbuf_addch(&d->buf, '\\n');\n  if (!strcmp(arg, \"-\")) {\n  if (strbuf_read(&d->buf, 0, 1024) < 0)\n- die_errno(_(\"cannot read '%s'\"), arg);\n+ die_errno(_(\"Cannot read '%s'\"), arg);\n  } else if (strbuf_read_file(&d->buf, arg, 1024) < 0)\n- die_errno(_(\"could not open or read '%s'\"), arg);\n+ die_errno(_(\"Could not open or read '%s'\"), arg);\n  stripspace(&d->buf, 0);\n\n  d->given = 1;\n@@ -355,7 +355,7 @@ static int list(int argc, const char **argv, const\nchar *prefix)\n      git_notes_list_usage, 0);\n\n  if (1 < argc) {\n- error(_(\"too many parameters\"));\n+ error(_(\"Too many parameters\"));\n  usage_with_options(git_notes_list_usage, options);\n  }\n\n@@ -410,7 +410,7 @@ static int add(int argc, const char **argv, const\nchar *prefix)\n      PARSE_OPT_KEEP_ARGV0);\n\n  if (2 < argc) {\n- error(_(\"too many parameters\"));\n+ error(_(\"Too many parameters\"));\n  usage_with_options(git_notes_add_usage, options);\n  }\n\n@@ -486,7 +486,7 @@ static int copy(int argc, const char **argv, const\nchar *prefix)\n\n  if (from_stdin || rewrite_cmd) {\n  if (argc) {\n- error(_(\"too many parameters\"));\n+ error(_(\"Too many parameters\"));\n  usage_with_options(git_notes_copy_usage, options);\n  } else {\n  return notes_copy_from_stdin(force, rewrite_cmd);\n@@ -494,11 +494,11 @@ static int copy(int argc, const char **argv,\nconst char *prefix)\n  }\n\n  if (argc < 2) {\n- error(_(\"too few parameters\"));\n+ error(_(\"Too few parameters\"));\n  usage_with_options(git_notes_copy_usage, options);\n  }\n  if (2 < argc) {\n- error(_(\"too many parameters\"));\n+ error(_(\"Too many parameters\"));\n  usage_with_options(git_notes_copy_usage, options);\n  }\n\n@@ -574,7 +574,7 @@ static int append_edit(int argc, const char\n**argv, const char *prefix)\n      PARSE_OPT_KEEP_ARGV0);\n\n  if (2 < argc) {\n- error(_(\"too many parameters\"));\n+ error(_(\"Too many parameters\"));\n  usage_with_options(usage, options);\n  }\n\n@@ -642,7 +642,7 @@ static int show(int argc, const char **argv, const\nchar *prefix)\n      0);\n\n  if (1 < argc) {\n- error(_(\"too many parameters\"));\n+ error(_(\"Too many parameters\"));\n  usage_with_options(git_notes_show_usage, options);\n  }\n\n@@ -770,7 +770,7 @@ static int merge(int argc, const char **argv,\nconst char *prefix)\n  if (strategy || do_commit + do_abort == 0)\n  do_merge = 1;\n  if (do_merge + do_commit + do_abort != 1) {\n- error(\"cannot mix --commit, --abort or -s/--strategy\");\n+ error(\"Cannot mix --commit, --abort or -s/--strategy\");\n  usage_with_options(git_notes_merge_usage, options);\n  }\n\n@@ -778,7 +778,7 @@ static int merge(int argc, const char **argv,\nconst char *prefix)\n  error(\"Must specify a notes ref to merge\");\n  usage_with_options(git_notes_merge_usage, options);\n  } else if (!do_merge && argc) {\n- error(\"too many parameters\");\n+ error(\"Too many parameters\");\n  usage_with_options(git_notes_merge_usage, options);\n  }\n\n@@ -916,7 +916,7 @@ static int prune(int argc, const char **argv,\nconst char *prefix)\n      0);\n\n  if (argc) {\n- error(_(\"too many parameters\"));\n+ error(_(\"Too many parameters\"));\n  usage_with_options(git_notes_prune_usage, options);\n  }\n\n@@ -937,7 +937,7 @@ static int get_ref(int argc, const char **argv,\nconst char *prefix)\n      git_notes_get_ref_usage, 0);\n\n  if (argc) {\n- error(\"too many parameters\");\n+ error(\"Too many parameters\");\n  usage_with_options(git_notes_get_ref_usage, options);\n  }\n\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 17094ad..aa7ffb2 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -53,7 +53,7 @@ static int prune_object(const unsigned char *sha1,\nconst char *fullpath,\n  if (show_only || verbose) {\n  enum object_type type = sha1_object_info(sha1, NULL);\n  printf(\"%s %s\\n\", sha1_to_hex(sha1),\n-       (type > 0) ? typename(type) : \"unknown\");\n+       (type > 0) ? typename(type) : \"Unknown\");\n  }\n  if (!show_only)\n  unlink_or_warn(fullpath);\n@@ -65,7 +65,7 @@ static int prune_cruft(const char *basename, const\nchar *path, void *data)\n  if (starts_with(basename, \"tmp_obj_\"))\n  prune_tmp_file(path);\n  else\n- fprintf(stderr, \"bad sha1 file: %s\\n\", path);\n+ fprintf(stderr, \"Bad sha1 file: %s\\n\", path);\n  return 0;\n }\n\n@@ -128,7 +128,7 @@ int cmd_prune(int argc, const char **argv, const\nchar *prefix)\n  add_pending_object(&revs, object, \"\");\n  }\n  else\n- die(\"unrecognized argument: %s\", name);\n+ die(\"Unrecognized argument: %s\", name);\n  }\n\n  if (show_progress == -1)\ndiff --git a/builtin/push.c b/builtin/push.c\nindex 57c138b..6af9d34 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -391,7 +391,7 @@ static int do_push(const char *repo, int flags)\n\n  if (!remote) {\n  if (repo)\n- die(_(\"bad repository '%s'\"), repo);\n+ die(_(\"Bad repository '%s'\"), repo);\n  die(_(\"No configured push destination.\\n\"\n     \"Either specify the URL from the command-line or configure a\nremote repository using\\n\"\n     \"\\n\"\n@@ -463,9 +463,9 @@ static int option_parse_recurse_submodules(const\nstruct option *opt,\n  else if (!strcmp(arg, \"on-demand\"))\n  *flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;\n  else\n- die(\"bad %s argument: %s\", opt->long_name, arg);\n+ die(\"Bad %s argument: %s\", opt->long_name, arg);\n  } else\n- die(\"option %s needs an argument (check|on-demand)\",\n+ die(\"Option %s needs an argument (check|on-demand)\",\n  opt->long_name);\n\n  return 0;\ndiff --git a/git.c b/git.c\nindex 481aa74..f9343d0 100644\n--- a/git.c\n+++ b/git.c\n@@ -654,7 +654,7 @@ int main(int argc, char **av)\n  if (skip_prefix(cmd, \"git-\", &cmd)) {\n  argv[0] = cmd;\n  handle_builtin(argc, argv);\n- die(\"cannot handle %s as a builtin\", cmd);\n+ die(\"Cannot handle %s as a builtin\", cmd);\n  }\n\n  /* Look for flags.. */\n-- \n2.4.0.2.g54b2a32.dirty\n\n\nRegards\nAlangi Derick Ndimnain\n"}]}