{"thread":{"id":"55185","subject":"noeol when redirect git log output to a file","startedAt":"2021-02-22T15:16:26Z","lastAt":"2021-02-22T17:21:20Z","messageCount":2,"participants":["Wang Yugui","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"417471","messageId":"20210222231406.CE72.409509F4@e16-tech.com","threadId":"55185","inReplyTo":null,"subject":"noeol when redirect git log output to a file","fromName":"Wang Yugui","fromEmail":"wangyugui@e16-tech.com","sentAt":"2021-02-22T15:14:07Z","receivedAt":"2021-02-22T15:16:26Z","isPatch":false,"sender":{"key":"wangyugui@e16-tech.com","avatar":null},"body":"Hi,\n\nnoeol when redirect git log output to a file.\n\n[root@T640 ~]# git log '--pretty=format:%h: %an: %s' -- hw/ >a.txt\n[root@T640 ~]# cat a.txt\nc2accaa: wangyugui:\n757bec2: wangyugui:\ncefb5d4: wangyugui:\n2fc0dbe: wangyugui:\n6cfe6cf: wangyugui:\ne8a94b1: wangyugui:\nba54c6a: wangyugui:\n7de214e: wangyugui:\n8f2588a: wangyugui:\n5834825: wangyugui:\ncd30711: wangyugui:\n8807c7d: wangyugui:\nedd4e92: wangyugui:\n0c6f3dd: wangyugui:\n38964f4: wangyugui:\n4fd21e8: wangyugui:\n52fa7b0: wangyugui:\n93f5ddb: wangyugui:\n47c7aa4: wangyugui:\nab23c1f: wangyugui: OK\n8002e69: wangyugui:\nda8a6d5: wangyugui:\ned2f4e0: wangyugui: baseline[root@T640 ~]#\n\nbut without redirect, it seems OK.\n[root@T640 ~]# git log '--pretty=format:%h: %an: %s' -- hw/\nc2accaa: wangyugui:\n757bec2: wangyugui:\ncefb5d4: wangyugui:\n2fc0dbe: wangyugui:\n6cfe6cf: wangyugui:\ne8a94b1: wangyugui:\nba54c6a: wangyugui:\n7de214e: wangyugui:\n8f2588a: wangyugui:\n5834825: wangyugui:\ncd30711: wangyugui:\n8807c7d: wangyugui:\nedd4e92: wangyugui:\n0c6f3dd: wangyugui:\n38964f4: wangyugui:\n4fd21e8: wangyugui:\n52fa7b0: wangyugui:\n93f5ddb: wangyugui:\n47c7aa4: wangyugui:\nab23c1f: wangyugui: OK\n8002e69: wangyugui:\nda8a6d5: wangyugui:\ned2f4e0: wangyugui: baseline\n[root@T640 ~]#\n\n\n[System Info]\ngit version:\ngit version 2.30.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.10.17-3.el7.x86_64 #1 SMP Mon Feb 22 10:43:13 CST 2021 x86_64\ncompiler info: gnuc: 4.8\nlibc info: glibc: 2.17\n$SHELL (typically, interactive shell): /bin/bash\n\n[Enabled Hooks]\nNone\n\nBest Regards\n王玉贵\n2021/02/22\n\n--------------------------------------\n北京京垓科技有限公司\n王玉贵\twangyugui@e16-tech.com\n电话：+86-136-71123776\n\n"},{"id":"417472","messageId":"xmqqk0r081en.fsf@gitster.g","threadId":"55185","inReplyTo":"20210222231406.CE72.409509F4@e16-tech.com","subject":"Re: noeol when redirect git log output to a file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-22T17:20:32Z","receivedAt":"2021-02-22T17:21:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wang Yugui <wangyugui@e16-tech.com> writes:\n\n> [root@T640 ~]# git log '--pretty=format:%h: %an: %s' -- hw/ >a.txt\n\nThis is an expected behaviour.\n\nNotice that the format string given above does not end in LF by\nitself (its final placeholder is the subject string without LF at\nthe end).  LF you'd see in the output all come from the \"log\"\nmachinery and not from the format string.  When the machinery adds\nLFs, there are \"separator\" and \"terminator\" behaviour, the former of\nwhich adds a separating LF between each item, while the latter adds\na terminating LF after each item.\n\n\"--pretty=format\" is defined to use a separator semantics that is\nsuited to show multi-line items, each of which ends in LF on its own\n(think of --pretty=format:\"by %an%n%b\").  Using terminator behaviour\nyou'd get an useless extra LF at the end for such a format, and\nseparator behaviour lets you avoid it.\n\n\"git log --help\" and find \"tformat\", to learn more.  --format=<fmt>,\ninstead of --pretty=format:<fmt>, may also help.\n"}]}